Filter löschen
Filter löschen

Unrecognized Variable when running a graph

1 Ansicht (letzte 30 Tage)
Kailin Johnsson
Kailin Johnsson am 10 Nov. 2020
Kommentiert: Kailin Johnsson am 10 Nov. 2020
Hello,
I am tyring to run a very simple code, however every time I use the a variable in this locaiton on MatLab, it says the variable is not recognized despite being defined... any suggestions? When I run the code without multiple formulas input it works fine. Thanks!

Akzeptierte Antwort

David Hill
David Hill am 10 Nov. 2020
Move your plot function below the line (31) where variable E is defined.
  5 Kommentare
David Hill
David Hill am 10 Nov. 2020
Your were clearing E!
M= 451.7;
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]';
% For loop to generate seqeunce terms
for i=1:length(p)
F(i)=p(i)+r*p(i)*(1-p(i)/M)';
end
tBegin = 1790; % time begin
tEnd = 2010; % time end
% 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]';
Data = b;
Labels = [1790:10:2010]';
% Plot all models 1790-2010
plot(Labels,Data,'k-*',Labels,E,'b-*',Labels,F,'m-*');
title('Comparison of Models of US Census Data, 1790-2010');
legend('Data','Malthusian','Discrete Logistic');
axis([1780 2020 0 500]);%changed axis to more appropriate
Kailin Johnsson
Kailin Johnsson am 10 Nov. 2020
Ah! Okay! I have removed this and now the graph is populating! THANK YOU!!!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Graphics Object Identification finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by