Search code examples
matlabif-statementis-empty

Matlab if x = 0×1 empty double column vector


What's the correct syntax for

if x = 0×1 empty double column vector

x = 5

end

I've tried this:

if x == [] 

x = 5

end

But it doesn't seem to work, and I'm not sure how else to do this.

To put it another way, I get this error message when I try to write x to something: Unable to perform assignment because the size of the left side is 1-by-1 and the size of the right side is 0-by-1., so I'm trying to implement something that just makes x zero rather than empty.


Solution

  • From @crisluengo

    if isempty(x)