jessysmith8109 jessysmith8109
  • 23-08-2019
  • Computers and Technology
contestada

convert for loop to while loop, that is the script

z1=zeros(10);
for x=1:10
for y=1:10
z1(x,y)=x^2-3*y
end
end
z1

Respuesta :

ExieFansler ExieFansler
  • 04-09-2019

Answer:

To convert for loop to while loop we have to first declare and initialize the integers or variables that will work as an counter.

script will be

z1=zeros(10);

x=1

while x<10

y=1

while y<10

z1(x,y)=x^2-3*y

y=y+1

end

x=x+1

end

z1

Remember that we have to update the counter every time that we not need to be done for loop.

Answer Link

Otras preguntas

Find the derivative of f(x) = 2x2 + 7x at -3. That is, find f'(-3).
a lauguage that means "peope of the coast"
Who announced the winning lottery number? 2 points A)the reporter B)children C)the lottery official D)Julio Iglesias
Divide the number of meters by______ to find the number of laps?
1 Correct the mistakes in the sentences. Write down the corrected sentence. 1 You can't to smoke here. 2 You notallowed to leave the classroom during the lesson
11. What happens during the S phase of the cell cycle?The cell makes daughter cells.The cell doubles in size.The cell copies its organelles.The cell copies its
Find the area of the parallelogram round to the nearest tenth if necessary
SOMEONE, PLEASE HELP QUICK Which statement about solving inequalities is true? Adding the same value to both sides of an inequality does not change the solution
What is South Africa’s biggest economic challenge?
How is judicial review a check on the legislative and judicial branches?