Execution of script ode45 as a function is not supported/Error in pop (line 9) [t,p] = ode45(@yprime,[0,tfin],pinit,options);
16 views (last 30 days)
Show older comments
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
0 Comments
Answers (1)
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.
0 Comments
See Also
Categories
Find more on Ordinary Differential Equations in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!