How can i change the result in the annualpayment in the table to a number with 4 decimal, and not in exponentioal form
1 view (last 30 days)
Show older comments
Shane Jasmine
on 24 Oct 2023
Commented: Shane Jasmine
on 24 Oct 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 Comments
Accepted Answer
Walter Roberson
on 24 Oct 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.
More Answers (0)
See Also
Categories
Find more on Whos in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!