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

What element is reduced in the following chemical reaction? Cu + 2H 2SO 4 → CuSO 4 + SO 2 + 2H 2O O H S H2O Cu
how do you find one side length of a square that has a area of 289
Please answer this i really need help.
when recounting this story which characters are most important to include
Which of the following values are solutions to the inequality -2> 4x-6?
PLS HELPPPPP Manny is writing a paper about whether violence in video games makes kids more violent. He found a news article about violence in video games on a
Chemistry question. Image attached.
whuch term best describes the situation in which a sleep medication taken with alcohol
if you are going to compose a song, how will you make it?​
Wanna know something about when you cry? If they're happy tears, they come from the left eye first, if they're sad tears, they roll from the right eye first. So