Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

For loop and array type

1 visualización (últimos 30 días)
Noah Kilps
Noah Kilps el 18 de Sept. de 2020
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
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.

Respuestas (1)

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

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by