how to get scientific notation out of answer
4 views (last 30 days)
Show older comments
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.
0 Comments
Answers (1)
See Also
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!