필터 지우기
필터 지우기

How to reference every column individually in a growing matrix

조회 수: 1 (최근 30일)
Alejandro Navarro
Alejandro Navarro 2019년 3월 16일
댓글: Alejandro Navarro 2019년 3월 16일
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