How to plot the values found in a for loop?
1 view (last 30 days)
Show older comments
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.
0 Comments
Answers (1)
David Hill
on 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 Comments
See Also
Categories
Find more on Graphics Performance in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!