How to plot two calculated values in for loop ?

10 ビュー (過去 30 日間)
Bora K
Bora K 2019 年 10 月 31 日
コメント済み: Bora K 2019 年 10 月 31 日
Hello,
I have a problem with plotting the values that I found inside the 'for loop'. I want to plot v_corr and v, but when I run this v gets 180 same values inside the matrix? Could you help me to solve it?
Thanks a lot in advance!
clc
clear
M = 0:1.001:180;
e = 0:0.00557:1;
v = zeros(length(M),length(e));
for i = 1:length(M)
for j = 1:length(e)
E = atand((sind(M))/(cosd(M)-e));
v(i,j) = 2.*(atand(tand(M/2).*(1+e)/(1-e)));
v_corr(i,j) = 2.*(atand(sqrt((1+e)/(1-e)).*(tand(E/2))));
end
end
  1 件のコメント
darova
darova 2019 年 10 月 31 日
YOu forgot indexes
M(i) e(j)

サインインしてコメントする。

採用された回答

Bhaskar R
Bhaskar R 2019 年 10 月 31 日
Hi Bora KAMACI , What is the need of the for loops over here?
We can notice in your code that you used Solve systems of linear equations(/ symbol) but I assume ./ is the actual division operation as
clc
clear
M = 0:1.001:180;
e = 0:0.00557:1;
%v = zeros(length(M),length(e));
% changed division operation insted of / operator
E = atand((sind(M))./(cosd(M)-e));
v = 2.*(atand(tand(M/2).*(1+e)./(1-e)));
v_corr = 2.*(atand(sqrt((1+e)./(1-e)).*(tand(E/2))));
figure, plot(v), title('v')
figure, plot(v_corr), title('v\_corr')
Hope helps you
  1 件のコメント
Bora K
Bora K 2019 年 10 月 31 日
Thanks a lot, it worked!!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by