Filter löschen
Filter löschen

Plotting Two Consecutive Columns of Matrices

2 Ansichten (letzte 30 Tage)
Femi O. Jinadu
Femi O. Jinadu am 21 Dez. 2021
Kommentiert: Star Strider am 21 Dez. 2021
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

Akzeptierte Antwort

Star Strider
Star Strider am 21 Dez. 2021
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 Kommentare
Femi O. Jinadu
Femi O. Jinadu am 21 Dez. 2021
Hi, thanks
I've figured it out, thanks so much.
Star Strider
Star Strider am 21 Dez. 2021
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Chunru
Chunru am 21 Dez. 2021
x = rand(202, 4); % 202x4 (not 4x202)
plot(x(:,1), x(:, 2), 'ro', x(:,3), x(:, 4), 'b*')

Community Treasure Hunt

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

Start Hunting!

Translated by