I have no idea why matlab does not understand this simple if function, any idea?

1 次查看(过去 30 天)
Simply put, this if condition never gets satisfied. It does work for other ns like 0 0.2,1.6,2 etc but does not work for n==1.2. Is this a software bug? I am using Matlab R2012a
for n=0:0.2:2
if n==1.2
test1=1
end
end
Thanks

采纳的回答

Walter Roberson
Walter Roberson 2013-12-24
  1 个评论
Amirhossein
Amirhossein 2013-12-24
Thanks Walter. I knew there was something deep going on here. I think the problem is that by default Matlab does not show the complete number. It is showing this to me: 1.200000000000000, so I thought that is the whole thing but I guess it is not.

请先登录,再进行评论。

更多回答(0 个)

类别

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