how to get scientific notation out of answer

4 views (last 30 days)
function [m,a]= IRA(MS,AI)
%IRA
%MS = Monthly Savings
%AI = Annual Interest
%m = Months until savings is greater than 1,000,000
%a = Actual Dollar Amount of savings for those months
%Brendan Proaps
%Due 9/29/20
%Asumming the Initial Deposit is 0
if nargin == 0
MS = 250;
AI = 6;
end
format shortG
TF = isscalar(MS);
if TF == 0
error('MATLAB:notScalar', 'Inputs must be scalars.')
end
ID = MS;
m = 0;
a = 0;
while a < 1000000
ID = MS + ID.*(1 + (AI./1200));
a = ID-MS;
m = m+1;
end
if m > 600
m = 600;
end
m = m;
a = a;
end
Using this function, I get
>> [m,a]=IRA(200,11)
m =
421
a =
1.004e+06
How do I get the a to not be in scientific notation? None of the format options(ex. shortG) are working.

Answers (1)

madhan ravi
madhan ravi on 29 Sep 2020
format longg

Categories

Find more on Develop Apps Using App Designer 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!