필터 지우기
필터 지우기

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 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