How to plot the values found in a for loop?

5 vues (au cours des 30 derniers jours)
Nick Kavouris
Nick Kavouris le 24 Sep 2020
Commenté : David Hill le 24 Sep 2020
I have the following code
for g=((-3*pi())/2):0.1:0
Ebca=X*(Ex*cos((pi()/6)+g)^2+Ey*sin((pi()/6)+g)^2+Gamxy*sin((pi()/6)+g)*cos((pi()/6)+g))
Ebcb=Ex*cos(-(pi()/6)+g)^2+Ey*sin(-(pi()/6)+g)^2+Gamxy*sin(-(pi()/6)+g)*cos(-(pi()/6)+g);
Ebcc=Ex*cos((pi()/2)+g)^2+Ey*sin((pi()/2)+g)^2+Gamxy*sin((pi()/2)+g)*cos((pi()/2)+g);
end
I need to plot each Ebca, Ebcb, Ebcc value found in the loop with respect to g, how would i do this?
I know i need to create an array with the values found for each function with each value of g but I do no know how to do this.

Réponses (1)

David Hill
David Hill le 24 Sep 2020
Are X, Ex, Ey, Gamxy constants not listed? Recommned executing without loop; otherwise you need to index Ebca/Ebcb/Ebcc. Currently you are overriding them during each loop execution.
g=-3*pi/2:0.1:0
Ebca=X*(Ex*cos((pi/6)+g).^2+Ey*sin((pi/6)+g).^2+Gamxy*sin((pi/6)+g).*cos((pi/6)+g));
Ebcb=Ex*cos(-(pi/6)+g).^2+Ey*sin(-(pi/6)+g).^2+Gamxy*sin(-(pi/6)+g).*cos(-(pi/6)+g);
Ebcc=Ex*cos((pi/2)+g).^2+Ey*sin((pi/2)+g).^2+Gamxy*sin((pi/2)+g).*cos((pi/2)+g);
plot(g,Ebca,g,Ebcb,g,Ebcc);
  3 commentaires
Nick Kavouris
Nick Kavouris le 24 Sep 2020
the code you provided me worked beautifully! thank you for the assistance
David Hill
David Hill le 24 Sep 2020
If you get a change, please accept the answer to close the question.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Graphics Performance dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by