How to plot the values found in a for loop?
5 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (1 件)
David Hill
2020 年 9 月 24 日
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 件のコメント
参考
カテゴリ
Help Center および File Exchange で Graphics Performance についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!