For loop Stop error

6 visualizaciones (últimos 30 días)
Rajat Ahuja
Rajat Ahuja el 28 de Oct. de 2018
Respondida: madhan ravi el 28 de Oct. de 2018
In the following,I want the loop to exit and print the value of i, when Price1 becomes equal to Price.However,Matlab just gives i=0.3 always(the last value of i in the for loop). What's wrong?
Price=1.8766
for i=0.2:0.005:0.3
Price1=blsprice(21,20,0.1,0.25,i)
if Price1==Price
disp(i)
end
end

Respuestas (1)

madhan ravi
madhan ravi el 28 de Oct. de 2018
Price=1.8766
for i=0.2:0.005:0.3
Price1=blsprice(21,20,0.1,0.25,i)
if Price1==Price
disp(i)
break
else
continue
end
end

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Productos

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by