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

whats 4x-7=29(to make x the subject)
what does this proverb meanbetter to be a free bird than a captive king
what bay cuts into and is almost completely surrounded by the Canadian shield?
a student measures the mass of an 8cm block of brown sugar to be 12.9g. what is the density of the brown sugar
I have four right angles but I am not just a rectangle. What am I?
Andrea's family stopped at the gas station to get gas. At gas stations, the price of gas per gallon is given to the nearest thousandth. In order to determine ho
I have four right angles but I am not just a rectangle. What am I?
The effect of alcohol varies from one person to another, mostly because it depends on the blood alcohol concentration, or BAC. What does blood alcohol concentra
what does 5.2E11 mean on a calculater
How to change 0.393 into a fraction