# How to plot from matrix

3 vues (au cours des 30 derniers jours)
Steve le 14 Déc 2020
Commenté : David Hill le 14 Déc 2020
If I have matrix that the value change for every iteration by n, Ex : A=[a b c; d e f; g h i]
How can I plot the value of first row first column which is (a) vs n. (a) in y axes and n in x axes. And then I also want to plot second row second column which is (e) vs n in the same graph.
##### 0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

### Réponses (1)

David Hill le 14 Déc 2020
How are you storing the matrix during each iteration? Did you create a thrid dimension?
for k=1:100
A(:,:,k)=[a b c; d e f; g h i];
end
If so, after completing your loop you could easily plot your desired data:
plot(n,A(1,1,:),n,A(2,2,:));%not sure what n is (n=1:100)?
##### 2 commentairesAfficher AucuneMasquer Aucune
Steve le 14 Déc 2020
n is below :
for n=1:5
A =[a b c; d e f; g h i];
end
Can you help me how to plot first row first column (a) vs n. (a) in y axes and n in x axes.
And then I also want to plot second row second column which is (e) vs n in the same graph.
David Hill le 14 Déc 2020
You need to do something like:
for n=1:5
A(:,:,n) =[a b c; d e f; g h i];%assuming a,b,c,d,e,f,g,h,i are changing each iteration
end
n=1:5;
plot(n,A(1,1,:),n,A(2,2,:));

Connectez-vous pour commenter.

### Catégories

En savoir plus sur Discrete Data Plots 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!

Translated by