Execution of script ode45 as a function is not supported/Error in pop (line 9) [t,p] = ode45(@ypr​ime,[0,tfi​n],pinit,o​ptions);

조회 수: 15 (최근 30일)
I have been betting errors in pop.m and yprime.m, how do i solve these errors
>> yprime
Not enough input arguments.
Error in yprime (line 6)
f = p * ( 1-p + ((a*p)/(1+b*p)));
>> pop
Execution of script ode45 as a function is not supported:
/Users/laurenashby/Documents/MATLAB/ode45.m
Error in pop (line 9)
[t,p] = ode45(@yprime,[0,tfin],pinit,options);
pop code
global a b count
count=0;
[a,b,pinit,tfin,tol, tol2, tol3] = readvars("Data1.txt","Delimiter"," "); %call in an assigns variable using external file
options=odeset('RelTol',tol,'AbsTol',tol); %creates options
[t,p] = ode45(@yprime,[0,tfin],pinit,options);
figure(1);
plot(t,p);
xlabel('Time')
ylabel('Population')
title('Logistic Population Growth')
Other code
function f = yprime(~,p)
global a b count
count = count+1;
f = p * ( 1-p + ((a*p)/(1+b*p)));
end
Data file
1 2 2.4 100 0.001 0.00001 0.0000001

답변 (1개)

Steven Lord
Steven Lord 2021년 10월 5일
/Users/laurenashby/Documents/MATLAB/ode45.m
This script file is preventing MATLAB from running the ode45 function included with MATLAB. As I suggested in your previous post, rename or remove it.

카테고리

Help CenterFile Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by