Effacer les filtres
Effacer les filtres

Why does my discrete transfer function block cause a Simulink "domain error"?

3 vues (au cours des 30 derniers jours)
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?

Réponse acceptée

MathWorks Support Team
MathWorks Support Team le 23 Fév 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. 

Plus de réponses (0)

Catégories

En savoir plus sur Interactive Model Editing dans Help Center et File Exchange

Produits


Version

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by