Spacience
Fidelis in Numeris: don't leave home without it!
Eth: 0x00cce8E2e56a543abc084920eee3f88eFD0921ea
Sunday, March 4, 2012
If Statement in Matlab
How to do a double if statement in Matlab (have a process execute under 2 or more conditions):
IF Test1
Matlab 2011a (and other versions) is tricky program to code correctly. Sometimes you think you are doing everything right and you are not getting any warning messages but things are still broken. It is easy to do this with the IF statement. Recently I coded up a double or compound if statement and I thought it was working properly. I had the script:
if Test1
However, Matlab 2011a will not check the second condition! Furthermore, it won't tell you there is a problem. The correct way to code this up to make sure both conditions are checked is to either brute force the problem by building in two if statements:
if Test1
Or the more refined version, use the && operator to make sure both conditions are evaluated:
IF Test1
Read more on
IF statements at Matlab documentation site
.
Happy Coding
-Láscal
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment