【发布时间】:2013-08-13 17:13:58
【问题描述】:
试图读取一个 txt 文件,然后遍历该 txt 文件的所有字符串。不幸的是没有让它工作。
fid = fopen(fullfile(source_dir, '1.txt'),'r')
read_current_item_cells = textscan(fid,'%s')
read_current_item = cell2mat(read_current_item_cells);
for i=1:length(read_current_item)
current_stock = read_current_item(i,1);
current_url = sprintf('http:/www.', current_item)
.....
我基本上尝试将单元格数组转换为矩阵,因为 textscan 输出单元格数组。但是现在我收到了消息
使用 cell2mat 时出错(第 53 行)无法支持包含元胞数组或对象的元胞数组。
非常感谢任何帮助
【问题讨论】:
-
这是因为您的元胞数组 (read_current_item_cells) 中包含元胞数组。
-
你能给出一个从 1.txt 读取的示例文本
-
当然,这些是基本的股票代码 APPL 下一行 MSFT 等。是否需要放入分隔符?
-
stackoverflow.com/questions/13540418/… 这将帮助您可视化您的问题。
-
谢谢,是的,我之前在寻找解决方案时发现了那个帖子,不幸的是我仍然无法修复它