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

The 1. A and B practice
A spring scale exerts a net force of 8.5 N on an object. What is the object's mass if it has an acceleration of 3.9 m/s2?
Which is more effective in transmitting information about a bird, Brancusi’s Bird in Space or John Audubon’s Wild Turkey?
Express 2.444... as a rational number
how to solve linear equations with inverse operations in each step example: 2x-4=11-x step one- 2x+x-4=11-x+xstep 2- 3x-4+4=11+4step3- 3x=153x/3=15/3 x=51. x =
PLZZZ HELP!!! When in the presence of sugar, yeast perform which process? A. an anaerobic process that has CO2 as a byproduct B. an anaerobic process that produ
Rome was able to create and maintain its empire because it had a
Which African kingdom was famous for trade with the Middle East and India?
3. The “reward circuit" is a system in the brain, that shoots out a feel-good 2 points chemical called
You are standing on a sheet of ice that covers the football stadium parking lot in Buffalo; there is negligible friction between your feet and the ice. A frien