Plot a nx2 matrix as points
34 次查看(过去 30 天)
显示 更早的评论
Hello, I have different nx2 matrices as outputs from earhquake signals, where n can vary. I would like to plot these matrices as points where n is the number of points and the first and second columns contain the x and y value for each point. Let us say I have a matrix A as follow:
A[0.5 2; 1.0 -0.8; 1.5 -2.5]
Herein, (0.5,2), (1.0, -0.8), and (1.5, -2.5) would the coordinates of the points I would like to plot. Thank you for your response.
0 个评论
采纳的回答
Torsten
2023-7-18
移动:Torsten
2023-7-18
A=[0.5 2; 1.0 -0.8; 1.5 -2.5];
plot(A(:,1),A(:,2),'o')
2 个评论
Dyuman Joshi
2023-7-18
A = [0.5 2; 1.0 -0.8; 1.5 -2.5];
scatter(A(:,1),A(:,2),'r*')
axis('equal')
更多回答(1 个)
Pranavkumar Mallela
2023-7-18
编辑:Pranavkumar Mallela
2023-7-27
Hi Jorge,
I understand that you want to plot the points obtained from a given nx2 matrix.
It can be done by extracting the x, y coordinates using array indexing. The graph can be plotted using the 'plot' function. Using '-*' in the 'plot' function will help you see the points.
Please find the code below:
A = [0.5 2; 1.0 -0.8; 1.5 -2.5]
x = A(:,1)
y = A(:,2)
plot(x, y, '-*')
For more information regarding extracting points, please refer the following documentation: https://www.mathworks.com/help/matlab/math/array-indexing.html
For more information regarding the 'plot' function, please refer the following documentation: https://www.mathworks.com/help/matlab/ref/plot.html
Hope this helps! Thanks!
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!