필터 지우기
필터 지우기

I want to solve it with the unknown

조회 수: 2 (최근 30일)
주선 문
주선 문 2022년 8월 25일
편집: Dyuman Joshi 2022년 8월 25일
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?

채택된 답변

Dyuman Joshi
Dyuman Joshi 2022년 8월 25일
편집: Dyuman Joshi 2022년 8월 25일
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개)

카테고리

Help CenterFile Exchange에서 Conversion Between Symbolic and Numeric에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by