Vector Manipulation - How to achieve this specific form?

조회 수: 2 (최근 30일)
Mathias Dirksmeier
Mathias Dirksmeier 2018년 10월 1일
댓글: Star Strider 2018년 10월 2일
Hi all,
I want to receive an expression like this: sos = {[1 8761]' [2 8762]' [3 8763]' [4 8764]' ... [8760 17520]'};
Do you have an idea on how to achieve this?

채택된 답변

Star Strider
Star Strider 2018년 10월 1일
Try this:
v1 = 1:17520; % Create Vector
v2 = reshape(v1, [], 2)'; % Reshape Vector To 2-Row Matrix
c = mat2cell(v2, 2, ones(1,size(v2,2))); % Create Cell Array
q1 = v2(:,1:5); % View Original Matrix Sample (Delete Later)
q2 = [c{1:5}] % View Cell Array Sample (Delete Later)
q2 =
1 2 3 4 5
8761 8762 8763 8764 8765
I created separate assignments for clarity. Note that ‘c’ is a (1x8760) cell array, the format requested.
  댓글 수: 4
Mathias Dirksmeier
Mathias Dirksmeier 2018년 10월 2일
Perfect! Thanks a lot!!
Star Strider
Star Strider 2018년 10월 2일
As always, my pleasure!

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

추가 답변 (1개)

Mathias Dirksmeier
Mathias Dirksmeier 2018년 10월 1일
Well, I surely know num2cell...
However, that wasn't the question, was it?
{[1 8761]' [2 8762]' [3 8763]' [4 8764]' ... [8760 17520]'};
How to achieve this specific form?

카테고리

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

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by