Getting a compound matrix to work

2 ビュー (過去 30 日間)
Sherman Ng
Sherman Ng 2022 年 2 月 12 日
コメント済み: Sherman Ng 2022 年 2 月 12 日
So my goal is to: Create a matrix with four columns: the first column contains the principal amount that is deposited in a bank, and the next three columns are the total amount (with interest) in the bank after [1 3 16] years. Use the principal amounts and compound interest rate specified in each question. Enter the matrix you created in the text box below each question.
For the first question, my first principal value is 800, and I am getting the wrong output. Am I not setting up the compound equation correctly? And how should I set up the [1 3 16] values?
  2 件のコメント
David Hill
David Hill 2022 年 2 月 12 日
How often are you compounding? Use should use the code box (so we can read your code and copy and paste it) if you want help. Like this:
n=[1 5 16];
p=800;
number_of_compounding=365;%daily compounding
interest=20;
f=p*(1+interest/100/number_of_compounding).^(number_of_compounding*n);
Sherman Ng
Sherman Ng 2022 年 2 月 12 日
I think it's yearly compounding but thanks for the tip!

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

採用された回答

Arif Hoq
Arif Hoq 2022 年 2 月 12 日
編集済み: Arif Hoq 2022 年 2 月 12 日
n=[1,3,16];
P=800;
t=20;
format shortG
y=P.*(1+t/100).^n-P; % Compound Interest,C.I.= P × (1+t)n - P
Year_1=y(1);
Year_3=y(2);
Year_16=y(3);
T=table(Year_1 , Year_3, Year_16)
writetable(T,'tabledata.txt','Delimiter','tab'); % save the table in the text file
  3 件のコメント
Arif Hoq
Arif Hoq 2022 年 2 月 12 日
編集済み: Arif Hoq 2022 年 2 月 12 日
can you please explain more what's your expectation ? output y is a row vector as your input n is a row vector. To creat a matrix you need multiple row and column.
Sherman Ng
Sherman Ng 2022 年 2 月 12 日
I think I got it to work using
M = table2array(T); % save the table in the text file
[P, M]

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSpecifying Target for Graphics Output についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by