Info

此问题已关闭。 请重新打开它进行编辑或回答。

For loop and array type

1 次查看(过去 30 天)
Noah Kilps
Noah Kilps 2020-9-18
关闭: MATLAB Answer Bot 2021-8-20
Hi,
I am having this issue where I am doing a for loop where I am trying to loop 73 times.
In this for loop, I am trying to put column vectors together to create a longer column vector. However, the vectors are not always the same array type. It seemed fine in putting a cell column vector together with a numeric column vector, until on the last loop I got this error:
Conversion to double from cell is not possible.
Here is what my for loop looks like:
for z = 1:73
Round(:,z) = [table2array(allcsvfiles{z,1}(:,4)); zeros(maxsize-size(allcsvfiles{z,1},1),1)];
end
Any ideas why it does not work on the last loop? I've tried making the second vector into cells, but it only makes through one loop. I've also tried making the first vector into numerics, but that also only makes it through the first loop. The only time I've gotten close to getting through all the loops is with the above code, but with only 72 loops.

回答(1 个)

Matt J
Matt J 2020-9-18
Best guess - your loop has reached a z for which allcsvfiles{z,1}(:,4) contains text. Use dbstop() to check.

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by