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

조회 수: 4 (최근 30일)
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?

채택된 답변

MathWorks Support Team
MathWorks Support Team 2018년 2월 23일
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개)

카테고리

Help CenterFile Exchange에서 Interactive Model Editing에 대해 자세히 알아보기

제품


릴리스

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by