I do miss Ruby type ‘if’ statements in MATLAB, so to overcome that I figured there has to be a simple way.
In ruby I could say: a = 1 if true. But in MATLAB one has to write three lines to get it done(I know, I can be lazy at times!). In MATLAB it would be:
To get similar statements as in Ruby I would be using a keyword ‘do’. So in MATLAB my statements would look like :
Not too bad, better than typing out three lines. So essentially, ‘do’ will be a function which will take in variable arguments and parse for if conditions and evaluate it for you in the caller workspace. I have left out the error checking. But here is the code: