フィルターのクリア

Unrecognized Variable when running a graph

1 回表示 (過去 30 日間)
Kailin Johnsson
Kailin Johnsson 2020 年 11 月 10 日
コメント済み: Kailin Johnsson 2020 年 11 月 10 日
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 Center および File ExchangeGraphics Object Identification についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by