-
Notifications
You must be signed in to change notification settings - Fork 0
/
sp_ismatrix.m
32 lines (30 loc) · 909 Bytes
/
sp_ismatrix.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
31
32
function TF = sp_ismatrix(data, num_dims)
% function TF = sp_ismatrix(data, num_dims)
%
% Returns TRUE only if data is a double matrix (at least 2x2)
% Returns FALSE otherwise (scalar, cell array)
% This behavior is different from Matlab's ismatrix()
%
% INPUTS:
% data : A Matlab data struct
% [num_dims]: [int] Default: 2. Number of dimensions in the matrix.
%
% OUTPUTS:
% TF: [bool]
%
% Sagi Perel, 01/2013
if(nargin < 1 || nargin > 2)
error('sp_ismatrix: wrong number of input arguments provided');
end
if(~exist('num_dims','var') || isempty(num_dims))
num_dims = 2;
end
TF = false;
if(isa(data,'double') && ~isempty(data) && ~iscell(data) && ~isscalar(data))
data_size = size(data);
if(ndims(data) == num_dims && all(data_size > 1) )
TF = true;
end
else
TF = false;
end