필터 지우기
필터 지우기

Indexing all the row data for each column

조회 수: 34 (최근 30일)
Vin
Vin 2021년 6월 23일
답변: millercommamatt 2021년 6월 23일
Hi everyone,
For example, if I had a matrix with 10 rows but variable column lengths for each row how would I iterate "for all row datapoints within each column"?
Right now using A(1:end,1:end) returns the entire matrix, but I would need to isolate each column of data.
Thank you in advance
  댓글 수: 3
Rik
Rik 2021년 6월 23일
You can't have non-rectangular arrays in Matlab.
You can approximately get the same effect by using a cell array, or by padding with NaN. The most optimal strategy will depend on what you want to do.
Vin
Vin 2021년 6월 23일
Sorry, I will try to be more clear.
The matrix would be 10x15 (15 being the most amount of actual data within a column), all other columns within the matrix that have less than 15 rows are padded with NaN.
Each column of data represents a waveform. My intentions would be to normalize all 10 columns of data from 0-100% to make all columns the same length.

댓글을 달려면 로그인하십시오.

답변 (1개)

millercommamatt
millercommamatt 2021년 6월 23일
For a 2D matrix, you can access a row as follows:
% Matlab indexing is row major
% return single row of matrix A
A(1,:)
A(2,:)
A(end,:)
%return single column of A
A(:,1)
A(:,2)
A(:,end)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by