How can I draw a graph from a given data in MATLAB
1 view (last 30 days)
Show older comments
user1234
on 9 May 2017
Answered: Walter Roberson
on 9 May 2017
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?
0 Comments
Accepted Answer
Walter Roberson
on 9 May 2017
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 Comments
More Answers (0)
See Also
Categories
Find more on MATLAB Report Generator in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!