MATLAB Answers

Can't enter if statement

조회 수: 6(최근 30일)
JTR
JTR 20 May 2014
답변: JTR 20 May 2014
Hello everyone!
I have the following code:
s_stepwidth = 0.005;
...
for s = 1:-s_stepwidth:0
...
if( s == 1 )
do something 1
if( s == 0.05 )
do something 2
if( s == 0.025 )
do something 3
...
end
My problem is now that the thrid and the second if does not work. Those if statements are never true. On the other hand the first one works (because nothing has been subtracted). Am I doing something wrong here (probably :D)?
Thanks

  댓글 수: 0

댓글을 달려면 로그인하십시오.

채택된 답변

Pedro Villena
Pedro Villena 20 May 2014
if round(s*1000)/1000 == 0.025,
...
end

  댓글 수: 0

댓글을 달려면 로그인하십시오.

추가 답변(1개)

JTR
JTR 20 May 2014
That worked! Thanks everyone!

  댓글 수: 0

댓글을 달려면 로그인하십시오.

제품

Community Treasure Hunt

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

Start Hunting!

Translated by