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

📄 par2struct.m

📁 麻省理工学院的人工智能工具箱,很珍贵,希望对大家有用!
💻 M
字号:
function S=par2struct(S,lin,tok,num)
%Function to process a line to a struct, tokenized by tok
mas=1;
while(mas)
   [t, lin] = strtok(lin, ',');
   if(isempty(t))
      t=lin;
      mas=0;
   end
   [t2,r2] = strtok(t,'=');
   if(~isempty(t2))
      campo=deblank(fliplr(deblank(fliplr(t2))));
      valor=deblank(fliplr(deblank(fliplr(r2(2:end)))));
      if(~isfield(S,campo))
         error([campo ' is not field of struct']);
      end
      
      switch(campo)
         case num
            valor=str2num(valor);            
      end
      %sprintf(':%s:%s:',campo,valor)   
      S=setfield(S,campo,valor);
   end
end

⌨️ 快捷键说明

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