How can i change the result in the annualpayment in the table to a number with 4 decimal, and not in exponentioal form
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Shane Jasmine
el 24 de Oct. de 2023
Comentada: Shane Jasmine
el 24 de Oct. de 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 comentarios
Respuesta aceptada
Walter Roberson
el 24 de Oct. de 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.
Más respuestas (0)
Ver también
Categorías
Más información sobre Whos en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!