Creating an array for a set number iterations
古いコメントを表示
I currently have the code that I have made for calculating a value Ct. But for this code I am trying to modify it such that I can calulate the array of values of Ct, for the values of i being from 1 to 30. I have tried a for loop but just cant get it to output the right values. F must be added to the last value of Ct. If i = 3 then there should be three elements in the array Ct which are [4000 4000 104000]
F = 100000;
i = 1;
Ct= F*0.04.*ones(i,1);
Ct(i) =Ct(i)+F;
T=length(Ct);
t=(1:1:T)';
採用された回答
その他の回答 (1 件)
F = 100000;
i = 3;
Ct= F*0.04.*ones(1,i);
Ct(end) = Ct(end)+F
4 件のコメント
Jd45ter
2022 年 4 月 16 日
Bruno Luong
2022 年 4 月 16 日
loop on i? You don't know to use for-loop ?
Bruno Luong
2022 年 4 月 16 日
Then post your code with for-loop, and please be more precise when asking question.
カテゴリ
ヘルプ センター および File Exchange で Loops and Conditional Statements についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!