Splitting an array?

조회 수: 2 (최근 30일)
Fercho_Sala
Fercho_Sala 2021년 4월 23일
댓글: Fercho_Sala 2021년 4월 26일
Hello everybody. Here is the issue.. having the array C{1,1} I normally don’t know the exact number of rows. How can I split that matrix in 2 parts?, I can use :
o = (C{1,1}(:,[1:end/2]));
to split the first part, however the second part is not that easy because the number of rows varies at the interior in each ‘C’ array. Thank you.

채택된 답변

Jan
Jan 2021년 4월 23일
편집: Jan 2021년 4월 23일
Data = C{1,1};
Len = size(Data, 2);
Half = floor(Len / 2);
Part1 = Data(:, 1:Half);
Part2 = Data(:, Half+1:Len);
It is not clear to me, what this means: "second part is not that easy because the number of rows varies at the interior in each ‘C’ array"
By the way, 1:x is a vector already. The square brackets are Matlab concatenation operator. [1:x] concatenates 1:x with nothing and is a waste of time in consequence.
  댓글 수: 6
Fercho_Sala
Fercho_Sala 2021년 4월 26일
편집: Fercho_Sala 2021년 4월 26일
@Jan is it possible to plot each item within 'C1' or 'C2' in a subplot structure (4x4) (of course it will be several independent windows) using the 'imagesc' function with the same loop structure? if so, how could you do it?
Fercho_Sala
Fercho_Sala 2021년 4월 26일
@Jan any comments?

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

추가 답변 (0개)

카테고리

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

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by