Plotting the first column of each page on one plot

조회 수: 1 (최근 30일)
LRW
LRW 2021년 5월 20일
답변: Girijashankar Sahoo 2021년 5월 20일
I have a matrix (101x11x8). An example of my data is attached 'Example.mat' and I am using MATLAB R2020a.
I want to plot the 1st column of every page (the third dimension of the matrix) on the same plot (and subsequently the 2nd column of every page on the same plot etc.). My first thought was to use the hold on function, but that doesn't seem to work. Here is what I have tried so far:
for i = size(H_Amputated,3)
plot(H_Amputated(:,1,i))
title('Ankle Angle')
hold on
end
This gives me the following image, which is the column from the last page so it doesn't appear that the hold on function is doing what I want it to:
Any ideas of how to plot the 1st column from each page on the same plot?
Thanks in advance.

채택된 답변

Mathieu NOE
Mathieu NOE 2021년 5월 20일
hello
simply because your not really doing the loop from i = 1 to 8
this is wrong :
for i = size(H_Amputated,3)
this is right
for i = 1:size(H_Amputated,3)
legend added for my fun ! - have a good day !!
figure(1);
for i = 1:size(H_Amputated,3)
H_Amputated(:,1,i)
plot(H_Amputated(:,1,i))
title('Ankle Angle')
hold on
legstr{i} = (['Data ' num2str(i)]);
end
legend(legstr);

추가 답변 (1개)

Girijashankar Sahoo
Girijashankar Sahoo 2021년 5월 20일
%% here is i am taking an example might be helpful to you
%% I take take 3D matrix, here 8 number of page, each page has 11 coloumn and each coloumn has %% 101 element. I just plot 101 elemnet as single curve and In same figure 8 number number of graph
%% from each page. In this manner for 11 coloumn there is 11 graph will create
clc
clear all
M=rand(101,11,8);
for j=1:11
figure
for k=1:8
plot(M(:,j,k))
hold on
end
end

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by