フィルターのクリア

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 Center および File ExchangeConversion 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