Hi, I am trying to calculate four variables within a for loop. The goal is to find values for de and da, save each one into an individual array along with the initial a and e values, and then update a and e before starting again to obtain new values. ( I want arrays for a, e, de, da). The goal is to be able to plot each of these arrays against another array T. Any help is appreciated!

 採用された回答

Torsten
Torsten 2022 年 3 月 23 日
編集済み: Torsten 2022 年 3 月 23 日

0 投票

Qe = 12;
M = 1002;
aArr = zeros(M,1);
eArr = zeros(M,1);
daArr = zeros(M-1,1);
deArr = zeros(M-1,1);
T = [0:1000];
eArr(1) = 0.0549;
aArr(1) = 0.3844e9;
for m = 0:1000
deArr(m+1) = -(4.04562756e41 + (2.75561858e40)/Qe) * ((aArr(m+1))^(-13/2)) * eArr(m+1);
daArr(m+1) = -((8.09125512e41)*(eArr(m+1)^2) + ((1.16026046e40)/Qe)) * (aArr(m+1))^(-11/2);
%Cannot figure out how to save values to array for each iteration
eArr(m+2) = eArr(m+1) + (deArr(m+1) * 3.154e7);%ADVANCE SYSTEM
aArr(m+2) = aArr(m+1) + (daArr(m+1) * 3.154e7);
end
eArr = eArr(1:end-1);
aArr = aArr(1:end-1);

3 件のコメント

AJ99
AJ99 2022 年 3 月 23 日
Thanks for your response! Each of the arrays are filled with identical elements though. I cannot figure out why.
Torsten
Torsten 2022 年 3 月 23 日
編集済み: Torsten 2022 年 3 月 23 日
Put
format long
at the beginning of the script to see differences.
AJ99
AJ99 2022 年 3 月 23 日
Thanks again

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

質問済み:

2022 年 3 月 23 日

編集済み:

2022 年 5 月 20 日

Community Treasure Hunt

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

Start Hunting!

Translated by