Filter löschen
Filter löschen

How to reference every column individually in a growing matrix

1 Ansicht (letzte 30 Tage)
Alejandro Navarro
Alejandro Navarro am 16 Mär. 2019
Kommentiert: Alejandro Navarro am 16 Mär. 2019
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 Kommentare
madhan ravi
madhan ravi am 16 Mär. 2019
if you illustrate with a short example you can do with the in-built function/s.
Alejandro Navarro
Alejandro Navarro am 16 Mär. 2019
Hi madhan, can you please elaborate? which in-built function will output all the columns of a growing matrix separately?

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by