Graphing does not appear

Please Help my graph wont appear and my Y-axis intervals are off
clc;
clear all;
close all;
B=2500; %starting Balance of the account
C=50; %amount added per month
I=B*0.004; %claculating the interest of accoungt
t=0:1:216;%time intervals for graph counting by month
for i=0:1:216 %There are 216 months in 18 years, incrementing by 1 so per month
Bf=B+I+C; %calculating the New Balance of the Account
fprintf('%6.2f \n',Bf)
end
plot(t,Bf) %graphing values
xlabel('Time in Months')
ylabel('Balance of the Acount ($)')
title('College Fund')

回答(1 个)

The plot will appear if you subscript ‘Bf’:
for i=1:numel(t) %There are 216 months in 18 years, incrementing by 1 so per month
Bf(i)=B+I+C; %calculating the New Balance of the Account
fprintf('%6.2f \n',Bf(i))
end
However your code has other problems (the amount does not accrue), and since this appears to be homework, I will leave you to it.

类别

帮助中心File Exchange 中查找有关 Characters and Strings 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by