我对 MATLAB 相当陌生,并且在构建可以使用另一个 m 文件迭代的结构时遇到问题。我有i
受试者在每次t
试验中进行w
分段试验。我现在想存储每个段的特定时间点。这里称为startTime
and stopTime
。我尝试了以下方法(针对一个主题,一项试验):
i=1; %Testperson #
% Trial 1
t=1; %Trial #
w=1; %Segment 1
selectedData = setfield('selectedData',['Subj' num2str(i)],['Trial' num2str(t)],{w},'startTime',0.001*5000)
selectedData = setfield('selectedData',['Subj' num2str(i)],['Trial' num2str(t)],{w},'stopTime',24.5*5000)
w=2; %Segment 2
selectedData = setfield('selectedData',['Subj' num2str(i)],['Trial' num2str(t)],{w},'startTime',0.001*5000);
selectedData = setfield('selectedData',['Subj' num2str(i)],['Trial' num2str(t)],{w},'stopTime',24.5*5000);
w=3; %Segment 3
selectedData = setfield('selectedData',['Subj' num2str(i)],['Trial' num2str(t)],{w},'startTime',0.001*5000);
selectedData = setfield('selectedData',['Subj' num2str(i)],['Trial' num2str(t)],{w},'stopTime',24.5*5000);
w=4; %Segment 4
selectedData = setfield('selectedData',['Subj' num2str(i)],['Trial' num2str(t)],{w},'startTime',0.001*5000);
selectedData = setfield('selectedData',['Subj' num2str(i)],['Trial' num2str(t)],{w},'stopTime',24.5*5000);
似乎setfield
覆盖了我要存储的以前的值?有什么建议么?