📄 par2struct.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 + -