简体   繁体   English

对单元格数据进行加载

[英]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.

相关问题 如何从数据框单元格中删除“()”? - How to remove "()" from data frame cells? 将数据从数据库加载到字符串 - Load data from database to string 如何解析单元格并从Excel中删除所选数据 - How to parse cells and remove selected data from excel 如何使用PySpark拆分字符串数据并将数据加载到表中 - How to split string data and load data in table using PySpark 如何仅从数据框中返回任何列单元格包含某些特定字符串的行? - How to return only the rows from a data frame that any of the column cells contain some specific strings? 加入来自 Pandas 数据框的单元格并安全地作为一个字符串或.txt 文件 - Join cells from Pandas data frame and safe as one string or .txt file 需要帮助合并来自下面行的列中的字符串数据。 多列出现问题,在其他列的单元格中留下空数据 - Need help merging string data from column that runs into below rows. Problem in multiple columns, leaving empty data in cells for other columns 如何将离线文本单词列表中的数据加载到字符串中? - How to load data from offline text word list into string? 从字符串中的单元格插入值 - Inserting values from cells in a string 插入复制的单元格,然后使用替换功能引用回原始单元格 - Inserting copied cells then referencing back to original cells using replace function
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM