我有以下代码和错误。问题如下:
clear all, close all
%Reading data in from excel
[num,txt,raw] = xlsread('test.xlsx');
%Looking through the raw excel data to find all instances of 'Instruction: '
instructionindex = find(strcmp(raw,'Instruction: '));
%Making an array using a loop that takes the content of each cell in column 2, indexed by instructionindex
instruction = []
for i = 1:numel(instructionindex)
instruction = [instruction; raw{instructionindex(i),2}];
end
使用vertcat时出错 连接的矩阵的尺寸不一致。 test2中的错误(第27行) 指令= [指令;生{instructionindex(ⅰ),2}];
并且在工作区中我可以看到,当instructionindex为24 x1 double时,我只在循环内增加到7.这导致值为(!)“指令”为6 x 5 char。我不确定这是否与某些事实相关,即我试图在数组“指令”中汇总的内容是字符串。
我的问题:如何在数组“指令”中获取所有索引的24个内容以及导致我在7点停止的原因?
编辑:进一步澄清为什么我认为这与第2列中包含字符串的单元格有关:如果我使用 指令= [指令;生{instructionindex(i)中,4}]; 第4列包含数字,一切正常!我得到两个大小为24的向量,并且连接也起作用。