Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Matlab equivalent of Python's "pass" statement

Tags:

python

matlab

In python you can issue something like

if <condition>:
    pass

This can come in handy as a placeholder for future code placement. What's the equivalent of "pass" in matlab when it comes to these kind of uses?

like image 842
bergercookie Avatar asked Jul 20 '14 02:07

bergercookie


2 Answers

There is not equivalent for that, but since you have to declare the "end" of a function or a condition in MATLAB, you can leave it empty.

For example:

if (condition)
end

or just leave a comment:

if (condition)
    % future code here
end
like image 181
Christian Tapia Avatar answered Oct 23 '22 20:10

Christian Tapia


According to this:

http://www.mathworks.com/matlabcentral/answers/117519-do-nothing-command-in-matlab

You can just use a semicolon. You could also immediately go to end as Christian suggested.

The pass command is necessary in Python, because 1) indentation determines the scope for if/for/while or for functions, and 2) there is no way of indicating that a block has ended except to un-indent. The combination of these two makes a no-op command pretty much necessary for the parser to work correctly. In Matlab, you have end, so you don't have the same issue.

like image 4
TheSoundDefense Avatar answered Oct 23 '22 20:10

TheSoundDefense