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

is this linear or not?
magbigay ng halimbawa na nagpapakita ng pagkakaisa ng mga Pilipino at paano ito nakatulong sa bansa at sa mga mamamayang Pilipino?Need na po..
According to urban anomie theory the impersonal nature of city life extends to situations that do not call for social involvement. Please select the best answer
The cases which deal with theft, cheating and robbery are called
Elizabeth bought 6 lipsticks for $15. How many lipsticks can be bought for $60
Which is true of these lines?
The global population during WWI was about 2.3 billion. About what percent of the global population died in the war?​
Emily is 1.45 meters tall. At 11 a.m., she measures the length of a tree's shadow to be 26.05 meters. She stands 20.6 meters away from the tree, so that the tip
The temperature of a substance in an experiment changes by −8.7°F from 10 a.m. to 1 p.m. At 5 p.m., the temperature is 33.5°F. It is 23 of what the temperature
Which of the following best represents the most likely source of Mansa Midas wealth