MATLAB: If statement for changing size of vector…

if statementvector

I'm running a for loop which gives an output 'x'. This output can be a vector of size (n,1). However I want to assign d=0 when n is larger than 1?
Something like this:
if x == size(1,1)
d = double(Residual_d(x))
else if x ~= size(1,1)
d = 0
end
, where Residual_d is a previous symbolic function which outputs 'x'.
Thanks in advance!
However, the above does not work as the loop jumps straight through the if statement to the elseif statement.

Best Answer

You are taking the size of the value "1", not x. Did you mean something like this?
if size(x,1)==1
d = double(Residual_d(x))
else
d = 0
end