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
2019-3-16
if you illustrate with a short example you can do with the in-built function/s.
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrices and Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!