Plotting selected columns of a matrix

조회 수: 2 (최근 30일)
Farhan K
Farhan K 2020년 2월 27일
댓글: Star Strider 2020년 2월 28일
I have a 32x1544 matrix.
I want to plot the 1st 8 column as plot1, 2nd 8 columns as plot2 and the 3rd 8 columns as plot3.
So all the 3 seperate plots are 32x8 2D-plot
Please advise. Thanks

채택된 답변

Star Strider
Star Strider 2020년 2월 27일
I am not certain what you want as the result.
Try this:
M = rand(32,24) + (1:24); % Create Matrix
x = 1:32; % Independent Variable Vector
figure
for k = 1:3
subplot(3,1,k)
plot(x, M(:,(1:8)+(k-1)*8))
grid
end
Substitute your own matrix for ‘M’, and your independent variable vector for ‘x’.
  댓글 수: 4
Farhan K
Farhan K 2020년 2월 28일
The plots need to be 2D dimentional. Maybe imagesc function should be used. Like the below 2D plot
Star Strider
Star Strider 2020년 2월 28일
I had no idea what you wanted with respect to your original Question. To me ’plot’ means a 2D plot such as what I wrote, unless otherwise specified. The imagesc plot would likely work.
Another option would be surf:
figure
surf(Z)
axis('tight')
view(0,90)
Note that the y-axis in surf is what you would normally expect, however it is reversed in image or imagesc plots.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by