How can I draw a graph from a given data in MATLAB

조회 수: 1 (최근 30일)
user1234
user1234 2017년 5월 9일
답변: Walter Roberson 2017년 5월 9일
How one can draw a graph from a given data so that the first column is being taken as x-axis in MATLAB. Here, I want to generate a graph in Matlab from the following data where the first column should be the x-axis (Time must be the x-axis i.e. horizontal).
_
_________________________________________________
Time A B C D
__________________________________________________
1 0.84702 0.64419 0.61728 0.48538
2 0.76445 0.1864 0.39728 0.15959
3 0.04743 0.0412 0.09432 0.86721
4 0.4256 0.1458 0.05432 0.803192
5 0.9855 0.8242 0.5679 0.7102
___________________________________________________
So far I tried the following, first I saved this data file as 'myData.m'. Next, I load it on my Matlab window using the command 'load myData.m'. Then after, I have used the followig codes:
[n,p] = size(myData);
t = 1:n;
plot(t,myData)
But, it doesn't give me what I want. Please help?

채택된 답변

Walter Roberson
Walter Roberson 2017년 5월 9일
myData = [ 1 0.84702 0.64419 0.61728 0.48538
2 0.76445 0.1864 0.39728 0.15959
3 0.04743 0.0412 0.09432 0.86721
4 0.4256 0.1458 0.05432 0.803192
5 0.9855 0.8242 0.5679 0.7102]
plot(myData(:,1), myData(:,2:end))

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB Report Generator에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by