For loop Stop error

조회 수: 6 (최근 30일)
Rajat Ahuja
Rajat Ahuja 2018년 10월 28일
답변: madhan ravi 2018년 10월 28일
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

답변 (1개)

madhan ravi
madhan ravi 2018년 10월 28일
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

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by