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 have been some challenges that hannah faced in " the devils arithmetic"?
In the triangle below, what ratio is sec H?
As of 2011, incidence of which chronic disease had more than doubled tripled over the previous 31 years?
Write the augmented matrix for each system of equations.
PLEASE HELP ME THANK YOU I LOVE YOU
In what way does the European union affect the rest of the world
Children about age _____ can be toilet trained because of frontal lobe development.
Which line shows the first error in the solution?
How do abiotic factors affect organisms in an ecosystem?
which ones are the stressed syllables and which ones are the unstressed syllables