Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

Why isnt my graph?

1 visualización (últimos 30 días)
Hunter Steele
Hunter Steele el 9 de Oct. de 2019
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
dollars = 50000;
inflation = .02;
startAge = 23;
endAge = 65;
for year = startAge : 1 : endAge
dollars = dollars + (dollars * .02);
end
annual401kInterest = .08;
dollarsrequired = dollars / annual401kInterest;
fileID = fopen('Retirement.txt','w');
fprintf(fileID, '%.2f\r\n ', dollars);
fprintf(fileID, '%.2f\r\n ', dollarsrequired);
%% Part B
salary = 60000;
annualRaise = 0.05;
maxContribution = 19000;
personalContribution = [0.05; 0.1; 0.15; 0.2];
companyContribution = [0.05; 0.06; 0.06; 0.06];
totalDollars = 0;
interestGenerated = [0 0 0 0];
graphableDollars = [];
years = [];
for year = startAge : 1 : startAge + 30
salary = salary + (salary * annualRaise);
personalContributions = salary + personalContribution + maxContribution;
companyMatch = salary + companyContribution + maxContribution;
yearlyContribution = personalContributions + companyMatch ;
totalDollars = totalDollars + yearlyContribution;
interestGenerated = totalDollars * annual401kInterest;
totalDollars = totalDollars + interestGenerated;
for x = 1 : length(personalContribution)
fprintf(fileID, 'age: %g\tPersonal Contribution: $%.2f\r\n', year, personalContributions(x));
fprintf(fileID, 'age: %g\tCompany Contribtuions: $%.2f\r\n', year, companyMatch(x));
fprintf(fileID, 'age: %g\tInterest Generated: $%.2f\r\n', year, interestGenerated(x));
fprintf(fileID, 'age: %g\tCurrentDollars: $%.2f\r\n', year, totalDollars(x));
fprintf(fileID, '*********************************\n');
end
plot(years, graphableDollars)
for x = 1 : length(personalContribution)
fprintf(fileID, 'total dollars for %.2f interest: $%.2f\r\n', personalContribution(x), totalDollars(x));
fprintf(fileID, 'You are going to be $%.2f dollars ahead of your goal\r\n', totalDollars(x) - dollarsrequired );
end
  1 comentario
Hunter Steele
Hunter Steele el 9 de Oct. de 2019
Nvm I got it.

Respuestas (0)

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by