-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathisvec.m
31 lines (27 loc) · 848 Bytes
/
isvec.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
%ISVEC Test if vector
%
% ISVEC(V, L) is true (1) if the argument V is a vector of length L,
% either a row- or column-vector. Otherwise false (0).
%
% Notes:
% - Differs from MATLAB builtin function ISVECTOR which returns true
% for the case of a scalar, ISVEC does not.
% - Gives same result for row- or column-vector, ie. 3x1 or 1x3 gives true.
% - Works for a symbolic math symfun.
%
% See also ISHOMOG, ISROT, ISHOMOG2D, ISROT2D.
% Copyright 2022-2023 Peter Corke, Witold Jachimczyk, Remo Pillat
function h = isvec(vec, len)
arguments
vec
len {mustBeInteger}
end
if isa(vec, 'symfun')
h = logical( length(formula(vec)) == len);
elseif isnumeric(vec)
dims = size(vec);
h = logical(length(dims) == 2 && min(dims) == 1 && numel(vec) == len);
else
h = false;
end
end