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

16 views (last 30 days)
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

Answers (1)

Steven Lord
Steven Lord on 5 Oct 2021
/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.

Tags

Products

Community Treasure Hunt

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

Start Hunting!