Invalid operand. Variables of type "sym" cannot be combined with other models.
5 次查看(过去 30 天)
显示 更早的评论
Hello, how can I resolve the error "Invalid operand. Variables of type "sym" cannot be combined with other models." in this code. Separately if it works for me. Thanks
d=5;%sobreoscilacion
tp=4; %tiempo pico
k=100;
syms e w
ecA=((-e*pi)/sqrt(1-e^2))-log(d)== 0;
e= vpa(solve(ecA,e)); %valor epsilon
ecB=(pi/(w*(sqrt(1-e^2))))-tp==0;
w= vpa(solve(ecB,w)); %valor ohmega
%%%%
s=tf('s');
Q=((k*(w)^2)/(s^2+2*e+s+(w)^2))*exp(-tp*s);
Q_apro=pade(Q,1);
0 个评论
回答(1 个)
Aniket
2025-1-28
The error you are encountering is due to trying to combine symbolic variables with transfer function models directly. Symbolic computations (using "syms") and transfer function models (using "tf") need to be handled separately, and their results must be numeric before being used together.
The issue can be resolved by ensuring that the symbolic expressions are evaluated to numeric values before they are used in the transfer function as shown below:
% Convert symbolic results to numeric
e_num = double(e);
w_num = double(w);
% Define transfer function
s = tf('s');
Q = ((k*(w_num)^2)/(s^2 + 2*e_num*s + (w_num)^2)) * exp(-tp*s);
You can find more information regarding transfer functions in MATLAB from this documentation: https://www.mathworks.com/help/control/ref/tf.html#mw_0827229c-931e-45e3-b7dd-7b9afe12a334
Hope this helps!
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!