[英]Using load with data from cells
In my code I'm trying to use load with entries from a cell, but it is not working. 在我的代码中,我试图将load与单元格中的条目一起使用,但无法正常工作。 The portion of my code below produces a 3 dimensional array of strings. 我下面的代码部分生成3维字符串数组。 The strings represent the paths to file names. 字符串代表文件名的路径。
for i = 1:Something
for j = 1:Something Different
for k = 1: Yet Something Something Different
DataPath{j,k,i} = 'F:\blah\blah\blah\fileijk %file changes based on i,j,and k
end
end
end
In the next part of the code I want to use load to open the files using the path names defined in the code above. 在代码的下一部分中,我想使用load通过上面的代码中定义的路径名打开文件。 I do this using the code below. 我使用下面的代码来做到这一点。
Dummy = DataPath{l,(k-1)*TSRRange+m};
Data = load(Dummy);
The idea is for Dummy to take the string content out of DataPath so I can use it in load. Dummy的想法是将字符串内容从DataPath中取出,以便在加载时使用它。 By doing this I thought that Dummy would be defined as a string and not a cell, but this is not the case. 通过这样做,我认为Dummy将被定义为字符串而不是单元格,但事实并非如此。 How do I pull the string out of DataPath so I can use it with load? 如何将字符串从DataPath中拉出,以便可以在加载时使用它? Thanks. 谢谢。
I have to load the data this way because the data is located in multiple folders. 我必须以这种方式加载数据,因为数据位于多个文件夹中。 I can post more of the code if needed, but it is complex. 如果需要,我可以发布更多代码,但这很复杂。
Dummy
is a cell because you assigned a 3D cell array but are accessing a 2D cell with Dummy = Datapath{1,(k-1)*TSRRange+m}
Dummy
是一个单元格,因为您分配了3D单元格阵列,但正在使用Dummy = Datapath{1,(k-1)*TSRRange+m}
访问2D单元格
I don't believe that you can expect to access all cell elements I this way. 我不相信您会期望以这种方式访问所有单元格元素。 Instead, use three indices just as you did when creating it. 而是使用与创建索引时相同的三个索引。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.