How can I draw a graph from a given data in MATLAB
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
user1234
le 9 Mai 2017
Réponse apportée : Walter Roberson
le 9 Mai 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 commentaires
Réponse acceptée
Walter Roberson
le 9 Mai 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 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur MATLAB Report Generator dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!