Check for row or column vector in matlab -


i have function processes row vector. want make generic type of input vector. column or row. 1 solution thought preserve existing implementation , check input vector column or row type. how can perform check? iscolumn() or isrow() functions not work here!

first, verify input vector. isvector can here. or, use size, or of number of various artifices.

second, convert vector column vector.

vec = vec(:); 

third, write code expect column vector, since vec(:) that.

finally, save original shape of vector , reshape output vector expected same shape input. final code should vaguely this...

% test errors if ~isvector(vec)   error('the sky falling') end  % convert column form vecshape = size(vec);  % process vector outputvec = ... % stuff here  % reshape output same shape input outputvec = reshape(outputvec,vecshape); 

Comments