⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 chkdtyph.m

📁 阵列信号处理的工具箱
💻 M
字号:
function  [err, errStr] = ckdtyph(tvar, datatype1)%CHKTYPH Returns 0 if the variable has an allowed datatype and 1 otherwise.%%--------%Synopsis:%  [err, errStr] = ckdtyph(tvar, datatype1)%%Description:%  Returns 0 if the variable has an allowed datatype and 1 otherwise.%%Output and Input:%  err (BoolT): = 1 if the proposed data type is invalid, = 0 otherwise.%  errStr (StringT): Error message.%  tvar (Any type): Variable to test.%  datatype1 (StringT): Proposed data type.%%--------%Notations:%  Data type names are shown in parentheses and they start with a capital%  letter and end with a capital T. Data type definitions can be found in [1]%  or by "help dbtdata".%  [D] = This parameter can be omitted and then a default value is used.%  When the [D]-input parameter is not the last used in the call, it must be%  given the value [], i.e. an empty matrix.%  ... = There can be more parameters. They are explained under respective%  metod or choice.%%Known Bugs:%  Only the following datatypes are checked:%    RecVarT, StringT.%  Vector of DoaT is partially checked.%  Variables of all other data types are allowed regardless of the "datatype1"%  input parameter.%%References:%  [1]: Bj鰎klund S.: "DBT, A MATLAB Toolbox for Radar Signal Processing.%    Reference Guide", FOA-D--9x-00xxx-408--SE, To be published.%See Also:%  ckhdtype, dbtdata%%   *  DBT, A Matlab Toolbox for Radar Signal Processing  *% (c) FOA 1994-2000. See the file dbtright.m for copyright notice.%  Start        : 970725 Svante Bj鰎klund (svabj).%  Latest change: $Date: 2000/10/16 15:20:07 $ $Author: svabj $.%  $Revision: 1.18 $% *****************************************************************************errStr = '';err = 0;if (isempty(datatype1))  err = 1;elseif isstruct(tvar)  if (~strcmp(tvar.dataType,datatype1))    errStr = ['Variable is not of type ' num2str(datatype1) '.'];%    errStr = 'Illegal datatype of variable.';    err = 1;  endelseif (strcmp(datatype1,'Vector of DoaT'))  if ~(((size(tvar,1) == 1) | size(tvar,1) == 2) & ~any(any(imag(tvar))))    errStr = 'Variable is not a Vector of DoaT.';    err = 1;  end%ifelseif (strcmp(datatype1,'DoaT'))elseif (strcmp(datatype1,'RealScalarT'))  if ( ischar(tvar) | isempty(tvar) | iscell(tvar) | isstruct(tvar) | ...    ~isreal(tvar) | (max(size(tvar))>1) )    errStr = 'Variable is not of type RealScalarT.';    err = 1;  end%ifelseif (strcmp(datatype1,'IntScalarT'))   % Complex values not allowed.  if ( ischar(tvar) | isempty(tvar) | iscell(tvar) | isstruct(tvar) | ...    ~isreal(tvar) | (max(size(tvar))>1) | ~isinteger(tvar))    % Some of the tests can be removed.    errStr = 'Variable is not of type IntScalarT.';    err = 1;  end%ifelseif (strcmp(datatype1,'BoolT'))  if ( (tvar ~= 0) & (tvar ~= 1))    errStr = 'Variable is not of type BoolT.';    err = 1;  end%ifelseif (strcmp(datatype1,'IndexT'))  if ( ischar(tvar) |  iscell(tvar) | isstruct(tvar) | ...    ~isreal(tvar) | (size(tvar,1)>1) | ~isinteger(tvar))     % isempty(tvar) |    % Some of the tests can be removed.    errStr = 'Variable is not of type IndexT.';    err = 1;  end%ifelseif (strcmp(datatype1,'RealVectorT'))  if ( ischar(tvar) | isempty(tvar) | iscell(tvar) | isstruct(tvar) | ...    ~isreal(tvar) | (size(tvar,2)>1) )    errStr = 'Variable is not of type RealVectorT.';    err = 1;  end%ifelseif (strcmp(datatype1,'RealMatrixT'))  if ( ischar(tvar) | isempty(tvar) | iscell(tvar) | isstruct(tvar) | ...    ~isreal(tvar)  )    errStr = 'Variable is not of type RealVectorT.';    err = 1;  end%ifelseif (strcmp(datatype1,'StringT'))  if (((~isstr(tvar)) | (size(tvar,1)>1)))    err = 1;    errStr = 'Variable is not a StringT.';  end%ifelseif (strcmp(datatype1,'CellArrayT'))  if (~iscell(tvar))    err = 1;    errStr = 'Variable is not a CellArrayT.';  end%ifelseif (strcmp(datatype1,'StringVectorT'))elseif (strcmp(datatype1,'CxVectorT'))elseif (strcmp(datatype1,'CxMatrixT'))elseif (strcmp(datatype1,'CxScalarT'))elseif (strcmp(datatype1,'EmptyT'))  if (~isempty(tvar))    err = 1;    errStr = 'Variable is not an empty matrix.';  end%ifelse  err = 1;  errStr = 'Illegal datatype1 of variable.';end%if%endfunction ckdtyphfunction B = isinteger(var)% Returns 1 of all elements of the matrix have integer values (as apposed% to real values that not are integers).  if (~isempty(var))    B = (all(all((var == fix(var)))) & isreal(var) & ~ischar(var));  else    B = 0;  end%if%endfunction isinteger

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -