复制结构中的工作空间

时间:2014-09-19 11:52:43

标签: matlab vector structure workspace

我的工作区中有大约50个向量,我想将它们保存在结构中 最后,我想以这种方式访问​​每个向量:Structurename.vectorname
我该怎么办?

提前致谢

1 个答案:

答案 0 :(得分:1)

我不认为你真的想要变量Test1.resultsTest2.results。也许你更愿意拥有Test(1).resultsTest(2).results,你可以通过这个获得:

 Test = struct();
 for i = 1:10
     result = rand(1,5); % compute the result
     Test(i).result = result; % bookkeeping
 end

现在,您甚至可以迭代结果,其中第i个模拟的结果存储在Test(i).result中。

相关问题