How can i change the result in the annualpayment in the table to a number with 4 decimal, and not in exponentioal form
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Shane Jasmine
am 24 Okt. 2023
Kommentiert: Shane Jasmine
am 24 Okt. 2023
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1519601/image.png)
%Annual Payment for Loans
p = 55000; %in dollars
r = 0.066; %interest rate
n = 1:5; %year
%Formula to be Use
A = (p * ((r*(1+r).^n)./((1+r).^n - 1)));
year = n;
annualpayment = A;
Annual_payment_with_an_interest_rate = table(n',A','VariableNames', {'year (n)','annualpayment(A)'})
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 24 Okt. 2023
%Annual Payment for Loans
p = 55000; %in dollars
r = 0.066; %interest rate
n = 1:5; %year
%Formula to be Use
A = (p * ((r*(1+r).^n)./((1+r).^n - 1)));
year = n;
annualpayment = A;
Annual_payment_with_an_interest_rate = table(n',A','VariableNames', {'year (n)','annualpayment(A)'});
format shorte
Annual_payment_with_an_interest_rate
format short
Annual_payment_with_an_interest_rate
format long g
Annual_payment_with_an_interest_rate
format bank
Annual_payment_with_an_interest_rate
That is, the "format" command affects how a table is displayed at the command window.
However if you want to display 4 decimal digits at the command line then you will need to change the content of the table variable using round() and use format longg -- but if you do then since 58630 is an exact value with no cents then longg format will not display the cents. To go further than that you need to change the content of the tables in other more obscure ways.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Whos finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!