Unrecognized Variable when running a graph

2 次查看(过去 30 天)
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!

采纳的回答

David Hill
David Hill 2020-11-10
Move your plot function below the line (31) where variable E is defined.
  5 个评论
David Hill
David Hill 2020-11-10
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 2020-11-10
Ah! Okay! I have removed this and now the graph is populating! THANK YOU!!!

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Graphics Object Identification 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by