I want to solve it with the unknown
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
주선 문
el 25 de Ag. de 2022
Editada: Dyuman Joshi
el 25 de Ag. de 2022
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
t(i+1)=t(i)+h;
yprime=y(i)+h*f(t(i),y(i),s(i)); %slope
y(i+1)=y(i)+h*f(t(i+1),yprime,s(i+1));
fprintf('%.4f %.4f\n', t(i), y(i));
figure(1)
plot(t,y,'r-o');
xlabel('t values'); ylabel('y values');
grid on; hold on;
legend('y')
end
But there is a problem that input is not enough(Insufficient input arguments.)
then how can i fix it?
0 comentarios
Respuesta aceptada
Dyuman Joshi
el 25 de Ag. de 2022
Editada: Dyuman Joshi
el 25 de Ag. de 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
y(i+1)=y(i)+h*f(t(i+1),yprime,s(i+1))
To fix the problem, call your function handle with 5 input.
Also, defining syms variable is redundant as you are using a function handle.
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Conversion Between Symbolic and Numeric en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!