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

📄 list2rec.m

📁 matlab阵列信号处理工具箱
💻 M
字号:
function outRecVar = list2rec(list, inRecVar)% RECVAR, A package for new data structures in Matlab. % (c) FOA 1998. See the file rvright.m for copyright notice.%%  function outRecVar = list2rec(list)%%  Converts a list or a cell array to a record variable. %  The list or cell array must contain pairs of field names (strings) and%  field values.%  This function does not work with Matlab releases prior to release 5.%%  outRecVar RecVarT%  list      ListT%Example:%  >> list2rec({'name','Tom',  'age',45,  'mat',[1 3; 3 4]})%   %  ans = %      name: 'Tom'%      age: 45%      mat: [2x2 double]%% Start        : 980506 Svante Bj鰎klund (svabj).% Latest change: $Date: 1998/05/12 10:42:19 $ $Author: svabj $.% $Revision: 1.3 $% *****************************************************************************if (mod(length(list),2)), error('Number of list elements must be even.'), endif (nargin == 2)  % Change or add fields to an existing record variable.  outRecVar = inRecVar;  while (~isemptyl(list))    fName = get1stl(list);    list = getrestl(list);    fValue = get1stl(list);    list = getrestl(list);    outRecVar = setfield(outRecVar,fName,fValue);  end%whileelse  % Create a new record variable.  len = length(list);  fNames = {list{1:2:len}};  fValues = {list{2:2:len}};  outRecVar = cell2struct(fValues,fNames,2);end%if

⌨️ 快捷键说明

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