How to reference every column individually in a growing matrix

1 次查看(过去 30 天)
Hello all
Ive got a matrix, called "Matrix A".
It has 5 columns per every iteration of a "for" loop.
(that's 1 column for each of 4 datasets generated earlier on in the for-loop, plus a 5th "NaN" column used for spacing)
First iteration, Matrix A begins with 5 columns.... second iteration of the for-loop, matrix A ends up with 10 columns, 3rd iteration, 15 columns.
Now, I need to reference each column of that growing matrix INDIVIDUALLY, because the next function, called "padcat", adds "Nan" (Not a Number) to the ends of every column shorter than the absolute longest column, so that all columns in Matrix "A" end up the same length. You need that so you can plot the data in matrix A.
thing is, that padcat function can't take a matrix as input, only columns. I want all the columns in the PREVIOUS iteration's "A" matrix to go into the CURRENT iteration's padcat function. But the padcat function requires a list of every *column* to be used as an input.
But how can I reference every column in the previous matrix A, when the matrix itself grows every iteration of the for-loop?
I tried [A(:,1) , A(:,5K)]
Which is a range from the first column of matrix "A" to the column of A 5 times the number of iterations (K), but that just creates another matrix. It wont split up the matrix into columns
Thanks in advance
  2 个评论
madhan ravi
madhan ravi 2019-3-16
if you illustrate with a short example you can do with the in-built function/s.
Alejandro Navarro
Alejandro Navarro 2019-3-16
Hi madhan, can you please elaborate? which in-built function will output all the columns of a growing matrix separately?

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrices and Arrays 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by