lsim and transfer fcn block in simulink output different results
조회 수: 2 (최근 30일)
이전 댓글 표시
I simulate the same transfer function with lsim and transfer fcn block in simulink but I ended up with different results.
In Simulink, the block diagram is shown as follows, the input signal is ua = 400sin(2*pi*50*t), the sampling frequency is 10 kHz![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/873490/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/873490/image.png)
In matlab, the code is shown following, ua is the data from simulink and the same for ua.
numerator = [ 1 ];
denominator = [1 1];
sys = tf(numerator, denominator);
matlab_ia = lsim(sys, ua, t_simu);
Technically, they're exact the same with no differences, but when I got the error between them and drew them out, I get :
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/873495/image.png)
Although it's really small, it's not tolerable for my later application, which is used for PSO to find the transfer function.
Simulink transfer fcn block actually gave the closer results, but there's no PSO block in Simulink.
So I wondered why the lsim and transfer function generated different results and how I can use the lsim to get the same results as transfer function block or are there other alternative function in matlab.
There're similar questions but I didn't find those answering my questions.
댓글 수: 0
채택된 답변
Paul
2022년 1월 25일
편집: Paul
2022년 1월 25일
Simulink uses a continuous-time differential equation solver. The specific solver and solver parameters, like step size information, are in the model settings.
lsim() in the Control System Toolbox converts sys to a discrete time approximation assuming either a first- or zero-order-hold and then propagates the difference equations.
So it's not a surpise that the two results are not identical. The size of the difference between them will depend on the the block parameters entered for Ua, particularly the sample time, the Simulink solver and solver parameters, and the 'method' argument to lsim().
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 General Applications에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!