Even with all my effort, I can not get my plot to show a line, why?

3 views (last 30 days)
Jagger Garcia
Jagger Garcia on 5 Nov 2021
Commented: Jagger Garcia on 5 Nov 2021
clc; clear; format compact;
% Intitiating Variables
Obalance = 3000;
YC = 300;
time = i;
% Creating For Loop
for i = 1:1:216
balance = Obalance;
interest = Obalance*0.005;
Nbalance(i) = Obalance + interest + YC;
Obalance = Nbalance(i);
end
fprintf("%.2f", balance);
plot(1:1:216,balance)
xlabel('time');
ylabel('balance');

Answers (1)

Paul
Paul on 5 Nov 2021
At the end of your loop, the variable balance is a single number. Maybe you wanted
balance(i) = Obalance
so that balance is a 1x216 array?
  2 Comments
Jagger Garcia
Jagger Garcia on 5 Nov 2021
I troubleshot that myself and you were right, just had to stare at it some more I guess. Thank you for the help.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!