Check if input is a 4 element vector
古いコメントを表示
I'm trying to write an error check in a function code, which should check if the input is specifically a 4-element vector.
All i have so far is:
if ~isvector(x)
error('Inputs must be vector')
end
Is there a way to write a code in order to check if the input, x, is a 4-element (row) vector.?
I'd like it to throw an error if the input x is for example a 2-element row vector, and of course if it is not a vector.
Thanks
採用された回答
その他の回答 (1 件)
Turlough Hughes
2019 年 12 月 11 日
編集済み: Turlough Hughes
2019 年 12 月 11 日
if size(x,2)~=4 || ~isvector(x) || ~isnumeric(x)
error('Input must be a row vector of length 4')
end
カテゴリ
ヘルプ センター および File Exchange で Big Data Processing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!