How to plot the values found in a for loop?

5 visualizaciones (últimos 30 días)
Nick Kavouris
Nick Kavouris el 24 de Sept. de 2020
Comentada: David Hill el 24 de Sept. de 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.

Respuestas (1)

David Hill
David Hill el 24 de Sept. de 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 comentarios
Nick Kavouris
Nick Kavouris el 24 de Sept. de 2020
the code you provided me worked beautifully! thank you for the assistance
David Hill
David Hill el 24 de Sept. de 2020
If you get a change, please accept the answer to close the question.

Iniciar sesión para comentar.

Categorías

Más información sobre Graphics Performance en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by