not enough input arguments

1 次查看(过去 30 天)
hi, I'm trying to write a code about cstr simulation and my loop cant continue due to this error, I'm sure it has what it needs for just first iteration but it does not calculate after the k1 part, can you help me please.
clear; clc;
Ts = 0.1;
%t = [1:0.1:1000];
Da1 = 3;
Da2 = 0.5;
Da3 = 1;
x1(1) = 0.5;
x2(1) = 0.5;
x3(1) = 1.5;
u = 0.45;
d2 = 1;
for n=1:1000
k1x1(n) = Ts*f1_func(x1(n),x2(n),Da1,Da2)
k1x2(n) = Ts*f2_func(x1(n),x2(n),Da1,Da2,Da3,d2,u)
k1x3(n) = Ts*f3_func(x2(n),x3(n),Da3,d2)
k2x1(n) = Ts*f1_func(x1(n)+k1x1(n)/2,x2(n)+k1x2(n)/2,u);
k2x2(n) = Ts*f2_func(x1(n)+k1x1(n)/2,x2(n)+k1x2(n)/2,u);
k2x3(n) = Ts*f3_func(x1(n)+k1x1(n)/2,x2(n)+k1x2(n)/2,x3(n)+k1x3(n)/2);
k3x1(n) = Ts*f1_func(x1(n)+k2x1(n)/2,x2(n)+k2x2(n)/2,u);
k3x2(n) = Ts*f2_func(x1(n)+k2x1(n)/2,x2(n)+k2x2(n)/2,u);
%k3x3
k4x1(n) = Ts*f1_func(x1(n)+k3x1(n),x2(n)+k3x2(n),u);
k4x2(n) = Ts*f2_func(x1(n)+k3x1(n),x2(n)+k3x2(n),u);
%k4x3
x1(n+1) = x1(n)+1/6*(k1x1(n)+2*k2x1(n)+2*k3x1(n)+k4x1(n));
x2(n+1) = x2(n)+1/6*(k1x2(n)+2*k2x2(n)+2*k3x2(n)+k4x2(n));
%x3
end
k1x1 = -0.0875
k1x2 = 0.1075
k1x3 = -0.1250
Not enough input arguments.

Error in f1_func (line 3)
dx1 = 1 - x1(t) - Da1*x1(t) + Da2*x2(t)*x2(t);

采纳的回答

Walter Roberson
Walter Roberson 2024-1-7
You declare f1_func as expecting f1_func(x1,x2,Da1,Da2) but starting from
k2x1(n) = Ts*f1_func(x1(n)+k1x1(n)/2,x2(n)+k1x2(n)/2,u);
you only pass in three parameters.
Also
k1x2(n) = Ts*f2_func(x1(n),x2(n),Da1,Da2,Da3,d2,u)
you are passing in 7 parameters there, but
k2x2(n) = Ts*f2_func(x1(n)+k1x1(n)/2,x2(n)+k1x2(n)/2,u);
you are passing in 3 parameters there.
  9 个评论
Halil Ibrahim
Halil Ibrahim 2024-1-8
I'm still trying to fix that index problem you're encounetring when you try to run the code, thats my main problem right now. If I can manage to do that, I will then try to evaluate control parameters using sinusodial and staircase referrance signals, and I'm still open for any help you can give me for that topics. thanks in advance.
Sam Chak
Sam Chak 2024-1-8
I understand that the simulation code for the Adaptive PID controller is not completely fixed. However, I am not familiar with the RK4 version you coded. Now that the issue of passing extra parameters mentioned in your initial question has been resolved, it might be helpful to create a new question specifically addressing the "Index exceeds..." issue.

请先登录,再进行评论。

更多回答(0 个)

产品


版本

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by