I want to solve it with the unknown

1 view (last 30 days)
clc,clear;close all;
syms r Nddotmax;
f = @(t,y,s,r,Nddotmax) (r*((1-y)/Nddotmax)+s-0.0012*0.02*y); %y=Nddotexi,vmed=0.02,fdot=3*10^(-18),r=0.0012,s=Nsurv
a = 0; %input('initial ponit, a: ');
b = 100; %input('end point, b: ');
n = 10; %input('intervals, n: ');
alpha = 0; %input('initial condition, alpha: ');
h = (b-a)/n;
t=[a zeros(1,n+1)];
y=[alpha zeros(1,n+1)];
s=[0 zeros(1,n+1)];
for i = 1:n+1
yprime=y(i)+h*f(t(i),y(i),s(i)); %slope
fprintf('%.4f %.4f\n', t(i), y(i));
xlabel('t values'); ylabel('y values');
grid on; hold on;
But there is a problem that input is not enough(Insufficient input arguments.)
then how can i fix it?

Accepted Answer

Dyuman Joshi
Dyuman Joshi on 25 Aug 2022
Edited: Dyuman Joshi on 25 Aug 2022
You have defined your function handle as -
f = @(t,y,s,r,Nddotmax) (r*((1-y)/Nddotmax)+s-0.0012*0.02*y);
Which means it requires 5 inputs to give you an output. Though 't' isn't mentioned in the expression, so either remove it or check the expression again.
But you are only calling it with 3 inputs, that is why it is giving the error
yprime=y(i)+h*f(t(i),y(i),s(i)); %slope
To fix the problem, call your function handle with 5 input.
Also, defining syms variable is redundant as you are using a function handle.

More Answers (0)


Find more on Get Started with Symbolic Math Toolbox in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by