An error occurred while propagating data type 'double' through...
显示 更早的评论
Dear
I'm doing an iterative algorithm in MATLAB/Simulink/Matalb Function. However, when i run the simulation, the errors occurred.(please see the attached picture and code). If possible, please help me. Thank you very much for your help.


function gamma = cg(gamma0,voutx,tao,e1,e2,M)
beta1=gamma0(1);
beta2=gamma0(2);
beta3=gamma0(3);
beta4=gamma0(4);
beta5=gamma0(5);%gamma0 is a vector.
xd=20;%设定位置x
T=0.01;%积分步长
falf=fal(tao,0.5,0.1);
fal1=dfal(e1,0.7,0.1);
fal2=dfal(e2,0.95,0.1);
b0=1;
k=1;
N=100000;%times maximum
epsilon=1e-5;%parameter
gamma=gamma0;
while(k<N)
g=gradient(xd,voutx,fal1,fal2,falf,T,b0,M,gamma);%gradient
beta1=beta1-2*(xd-voutx)*M*(beta4*fal1*T*tao)/(1+(beta4*fal1*T+beta5*fal2)*T*b0);
beta2=beta2-2*(xd-voutx)*M*T*falf*(beta4*fal1*T+beta5*fal2)/(1+(beta4*fal1*T+beta5*fal2)*T*b0);
beta3=beta3-2*(xd-voutx)*M*((beta4*fal1*T+beta5*fal2)*T*T+T/b0)*falf/(1+(beta4*fal1*T+beta5*fal2)*T*b0);
beta4=beta4-2*(xd-voutx)*M*fal1/(1+(beta4*fal1*T+beta5*fal2)*T*b0);
beta5=beta5-2*(xd-voutx)*M*fal2/(1+(beta4*fal1*T+beta5*fal2)*T*b0);%the three parameters that need to be adjusted
gamma=[beta1;beta2;beta3;beta4;beta5];%vector
if(norm(g)<epsilon), break; end
end
19 个评论
Walter Roberson
2022-7-16
Were there other error messages as well?
Joe Jones
2022-7-17
Fangjun Jiang
2022-7-18
The "complete model" doesn't help to show the error. The error indicates there is a "chart" and points to the place, "ADRC_dingdian.../cgadrc2". Click that link and where does it lead to in the model? Show all block names to help identifying the model blocks.
Joe Jones
2022-7-18
Fangjun Jiang
2022-7-18
编辑:Fangjun Jiang
2022-7-19
Open the MATLAB Function block code, click "edit data" to see if there is anything obvious regarding the data types of the parameters and signals.
The code seems to have problems.
- In the while loop, k never increases so it is an infinite loop. You need to add k=k+1
- the usage of gradient() function is puzzling. xd is a constant. Why there are so many input arguments?
Fangjun Jiang
2022-7-19
There is one possibility. If "if(norm(g)<epsilon), break; end" is satisfied during the first iteration, then gamma is never assigned.
Add "gamma=gamma0" as the first line of the function as the default return value to resolve this error.
Joe Jones
2022-7-20
Fangjun Jiang
2022-7-20
Not like that!
Use your previous version of code
Add "gamma=gamma0" as the first line of the function, which means, right below the "function gamma=frcg(gamma0,voutx,tao,e1,e2,M)" line.
Joe Jones
2022-7-21
Walter Roberson
2022-7-21
Yes, negative to a fraction needs complex numbers.
Do complex numbers make sense for the physics involved?
Joe Jones
2022-7-21
Fangjun Jiang
2022-7-21
Check the dfal() function. I think the output y is supposed to be symmetric to the input x. Your function is NOT.
Check the literature to make sure it is implemented correctly. Plot out dfal() vs. x to verify.
Fangjun Jiang
2022-7-22
- The direct derivative (du/dt) operation usually would cause problem in digital simulation. Use an approximation of derivative if it is absolutely needed. In your model, two derivatives are multiplied but I didn't see where it is used. If it is for observation only, then delete or comment out all of them.
- In the solver settings, reduce the step size or reduce the relative tolerance, you might be able to get the simulation running without error.
- If there is a true algebraic loop, you need to find it and resolve it.
- ADRC is known to have digital simulation stability issues due to its non-linearity. Check the literature to see if there is recommendation on the settings for Simulink simulation.
Fangjun Jiang
2022-7-25
This is probably where the help from this community ends. The simulation of the Simulink model runs but it is extremely slow and it stopped due to instability of the simulation. You need to consult the expert in your field to resolve the problem. Most likely the parameters of the ADRC is too aggressive. Avoid directly derivative.
Joe Jones
2022-7-26
回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Simulink 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!









