Why does my discrete transfer function block cause a Simulink "domain error"?
8 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
MathWorks Support Team
el 23 de Feb. de 2018
Respondida: MathWorks Support Team
el 28 de Feb. de 2018
I have a model with a continuous transfer function block. Since I want to generate code from this model, I have changed this continuous transfer function block to a discrete transfer function block that uses the same coefficients as my continuous transfer function block. Now, even if I just simulate the model, I get this error saying "to compute complex results from real x, use 'sqrt(complex(x))'.
How can I avoid this error when using a discrete transfer function?
Respuesta aceptada
MathWorks Support Team
el 23 de Feb. de 2018
This error can be resolved by converting the coefficients for the discrete transfer function. A continuous and a discrete transfer function with the same coefficients can have different outputs. In this case, the outputs of the discrete transfer function with the continuous coefficients were negative and unstable, causing this error.
To find the equivalent discrete coefficients, start with a continuous S-domain transfer function - for example, 1/(Ls+R). Then, use the "c2d" function to convert this into a discrete transfer function. The "c2d" function requires a sample time input. For this model, the desired sample time was 0.0001.
>> TFc = tf(1,[L R]);
>> TFd = c2d(TFc, 0.0001, 'matched');
Enter the coefficients from "TFd" into your discrete transfer function block, and the error will be resolved.
Note that the "c2d" function is not supported for code generation, so this conversion will have to take place outside the simulation.
0 comentarios
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!