필터 지우기
필터 지우기

Plotting Two Consecutive Columns of Matrices

조회 수: 2 (최근 30일)
Femi O. Jinadu
Femi O. Jinadu 2021년 12월 21일
댓글: Star Strider 2021년 12월 21일
Hi,
I have 4 x 202 matrix, and I want to plot the columns in 2's e.g columns 1 and 2, next columns 3 and 4 as they represent X and Y coordinates. How can I do this?
Thanks

채택된 답변

Star Strider
Star Strider 2021년 12월 21일
First a (4 x 202) matrix defines a matrix of 4 rows and 202 columns. Assuming that it’s actually a (202 x 4) matrix, perhaps something like this —
M = randn(15, 4) % Prototype
M = 15×4
-1.4757 0.4730 -1.7963 0.5677 -1.4236 0.6301 -0.9039 -0.0171 -1.1303 1.3193 0.1080 0.2304 -1.2160 -0.9149 -0.3458 -1.0942 0.7360 0.9042 -0.1741 1.7954 0.1131 0.5694 1.0606 -0.2865 0.1741 -0.7245 -0.7010 1.2694 -1.8673 -0.5442 -0.6397 -2.0804 0.4837 0.0083 -0.6583 0.5971 -1.0150 -2.1755 0.5630 -0.2446
Mr = reshape(M, [], 2)
Mr = 30×2
-1.4757 -1.7963 -1.4236 -0.9039 -1.1303 0.1080 -1.2160 -0.3458 0.7360 -0.1741 0.1131 1.0606 0.1741 -0.7010 -1.8673 -0.6397 0.4837 -0.6583 -1.0150 0.5630
figure
plot(Mr(:,1), Mr(:,2), '.')
If the matrix actually is (4 x 202), transpose it first, then use the approach in this code example.
.
  댓글 수: 8
Femi O. Jinadu
Femi O. Jinadu 2021년 12월 21일
Hi, thanks
I've figured it out, thanks so much.
Star Strider
Star Strider 2021년 12월 21일
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.

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

추가 답변 (1개)

Chunru
Chunru 2021년 12월 21일
x = rand(202, 4); % 202x4 (not 4x202)
plot(x(:,1), x(:, 2), 'ro', x(:,3), x(:, 4), 'b*')

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by