This question is closed. Reopen it to edit or answer.

For loop and array type

1 view (last 30 days)
Noah Kilps
Noah Kilps on 18 Sep 2020
Closed: MATLAB Answer Bot on 20 Aug 2021
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)];
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.

Answers (1)

Matt J
Matt J on 18 Sep 2020
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!