Execution of script ode45 as a function is not supported ... Error in pop (line 12) [a,b] = ode45(@ypr​ime,[0,tfi​n],pinit);

Hi how do I fix this error message? Here is the code below.Im trying to plot logistic population growth.
global a
a = 2;
global b
b = 1;
tfin = 100; %tfin is the the length of time with you are solving for (time final)
pinit = 2.4; %establishes the initial p value, p(0)
[a,b] = ode45(@yprime,[0,tfin],pinit);
figure(1);
plot(a,b);
xlabel('Time')
ylabel('Population')
title('Logistic Population Growth')

Answers (1)

You've written a script file ode45.m that's taking precedence over the ode45 function included in MATLAB. Check where that script file is located and rename or remove it.
which -all ode45
/MATLAB/toolbox/matlab/funfun/ode45.m /MATLAB/toolbox/nnet/deep/@dlarray/ode45.m % Shadowed dlarray method
If you see an ode45.m that's not in the toolbox/ directory that's likely the culprit. Leave the files in either of those two locations (you may or may not have the one in toolbox/nnet) alone.
If you don't have another ode45.m then it's possible the file has been corrupted.

Products

Asked:

on 5 Oct 2021

Answered:

on 5 Oct 2021

Community Treasure Hunt

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

Start Hunting!