Graph Line at bottom of legend

1 view (last 30 days)
Hi all,
It appears the line which should be plotted is stuck the to bottom of the screen. I have a similar issue in the past, however it was corrected using a '.' in the equation... I have gone through and made sure these have been added hwoever I cannot seem to find the mistake.
% Discrete Logistic Model
% Parameter and intial condtions
clear
clc
Labels2 = [1790:10:1860]';
Labels = [1790:10:2010]';
r= (0.349)
% Carrying Capactiy
M= 330.0
X0= 3.929
p= [2.913 3.929 5.308 7.239 9.638 12.866 17.069 23.191 39.818 50.189 62.947 76.212 92.228 106.021 122.775 132.164 150.697 179.323 203.302 226.545 248.709 281.421 308.745]';
Data = p
A = Data(1:22,1).*(1-(Data(1:22,1)./M));
B = Data(2:23,1)-Data(1:22,1);
X = A\B;
r = X(1,1);
P0 = Data(1,1);
F = zeros(23,1);
F(1,1) = P0
% For loop to generate seqeunce terms
for i=2,23
F(i,1)=F(i-1,1)+r.*F(i-1,1).*(1-(F(i-1,1)./M))';
end
tBegin = 1790; % time begin
tEnd = 2010; % time end
% Time interval
t = (1790:10:2010)';
% Time Interval
a=(1790:10:2010)';
% Population
b= [3.929 5.308 7.239 9.638 12.866 17.069 23.191 31.443 39.818 50.189 62.947 76.212 92.228 106.021 122.775 132.164 150.697 179.323 203.302 226.545 248.709 281.421 308.745]';
% Plot
plot(Labels,Data,'b-*',Labels,F,'r-*');
hold on
legend('Census Data', 'Discrete Logistic Model');
axis([1790 2010 0 500]);
title('US Population Data');
ylabel('Population (Millions)');
%R2
SST = sum((Data-mean(Data)).^2);
SSE = sum((Data-F).^2);
R2 = 1- (SSE/SST)

Accepted Answer

Kailin Johnsson
Kailin Johnsson on 17 Nov 2020
Please disregaurd!!! I have found the error. I was using a common for i=2:23 instead of a semicolon! Sorry!

More Answers (0)

Categories

Find more on Graph and Network Algorithms 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!