【发布时间】:2013-12-23 01:10:20
【问题描述】:
我对 matlab 还很陌生,但是经过数小时的尝试寻找解决问题的方法后,我似乎不得不直接询问,因为我发现没有任何东西能直接帮助
我要做的是构建一个单元数组,其中包含我必须循环的各种变量。目前我已经设法很好地创建了这个单元格数组,但是循环会覆盖结果。我正在尝试寻找保存输出的方法并进行了管理,但仅限于不涉及单元格数组的示例:(
这是代码(如果看起来很糟糕,请原谅我):
subject = {'505','506'}
pathname_read = 'a path';
nsubj = length(subject);
curIndex=0;
for s=1:nsubj
Cond={'HiLabel','LowLabel'};
ncond=length(Cond);
for e=1:ncond;
curIndex=curIndex+1
line=line+1
curCond=Cond{e};
curFile=[pathname_read subject{s} '_' Cond{e} '.set'];
curSubject=subject{s};
curSet={'index' curIndex 'load' curFile 'subject' curSubject 'condition' curCond};
end
end
curSet 是建立起来的元胞数组。我已经看到了使用 curSet(e) 之类的方法从循环中提取的方法,但在这里它不起作用。
最终我想要的结果是这样的:
curSet=
{'index 1 'load' path/file 'subject' 505 'condition' HiLabel};
{'index 2 'load' path/file 'subject' 505 'condition' LoLabel};
{'index 3 'load' path/file 'subject' 506 'condition' HiLabel};
{'index 4 'load' path/file 'subject' 506 'condition' LoLabel};
我也想找到一种方法来获得 ;在每一行之后。我想它可能,一旦全部收集起来,就是一种字符串,因为它会“粘贴到一个看起来像这样的函数中
doSomething(A, 'command',{ My generated curSet });
【问题讨论】: