Ciao, ho una domanda da porre: devo procedere alla linearizzazione di un sistema creato con una matlab function ma mi dà un errore sulla struttura degli stati di simulazione.
3 次查看(过去 30 天)
显示 更早的评论
Lo script che utilizzo è il seguente:
% lo stato del sistema dinamico è dato da [z_eq;0;h_eq] dopo aver calcolato l'equilibrio del sistema.
z_eq=sqrt((0.2*i_eq)/(3*m*g))-1/3);
h_eq=((Kv+d)*(z_eq-K))^2/2*g*(Au)^2;
x_eq=[z_eq;0;h_eq];
u_eq=i_eq;
sistema_tc=linmod('progettoserbatoio',x_eq,u_eq);
il codice relativo alla matlabfunction che uso per costruire il foglio simulink progettoserbatoio è:
function [xdot,y]=fcn(x,u)
z=x(1); zdot=x(2); h=x(3);
xdot=[zdot; 0.2*i/(1+3*z^2)/m -g; (Kv*z - Kv*K)/At - Au*sqrt(2*g*h)/At];
y=x;
fatto run compare questo errore: error in linmod : the state of simulation must be specified as a vector of real doubles or a structure.
come risolvo?
si tenga conto che i valori di z_eq e x_eq risultano essere double complex.
Ringrazio anticipatamente per l'aiuto.
2 个评论
Varun
2023-8-18
Hello! Can you please share the values of variables such as i_eq, Au, Kv, etc. in a MAT file? This will help me run the code on my end and investigate the issue. Thanks!
回答(1 个)
Divit
2023-9-21
Hi Gabriele,
The linmod function is designed to accept state and input operating points for models that incorporate model blocks. Specifically, it anticipates the state argument to be either a vector consisting of real double-precision values or a structured data type.
The error in your code arises from the fact that the variable x_eq (representing the state) is not composed of real numbers but instead comprises complex numbers. This issue likely stems from the variable z_eq potentially being complex due to the utilization of the square root function when there is no real solution available.
It is advisable to carefully review the formula for the z_eq variable and ensure the correct usage of parentheses to properly handle complex solutions when needed.
To know more about linmod you can refer to the following documentation link:
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!