"IF" condition not working with "<="

3 次查看(过去 30 天)
Joyce Ai
Joyce Ai 2020-5-29
I am trying to compare two sets of data. One stored as a 1x3 struct as Norm.Block(i).Rlong, the other as Norm.Block(i).Llong
My code is as follows:
for i=1:3
if Norm.Block(i).Rlong <= Norm.Block(i).Llong
Coact.Block(i).RlongLlong=Norm.Block(i).Rlong/Norm.Block(i).Llong;
elseif Norm.Block(i).Rlong>Norm.Block(i).Llong
Coact.Block(i).RlongLlong=Norm.Block(i).Llong/Norm.Block(i).Rlong;
end
end
When i try to run it, the code does not run and in the bottom left corner on MATLAB it just shows "busy". I think the problem is in the if statement but I'm not sure how to solve it.
I am very very new to this so someone please helpe me the solution seems simple but I just can't get it to work :(
Thank you in advance
  3 个评论
Joyce Ai
Joyce Ai 2020-5-29
Thank you so so much this worked for me! Sorry about the question formatting, I wasn't aware of how to do that and thank you for editting it for me, I'll make sure to format it correctly next time. :) Thanks for your time!
Bjorn Gustavsson
Bjorn Gustavsson 2020-5-29
The only case I can see where this loop would consume a large amount of time is if some of the Rlong and Llong fields have ended up as large enough arrays to make the Rlong/Llong produce a very big matrix.

请先登录,再进行评论。

回答(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