Simulink Difference Equation Implementation
古いコメントを表示
I have a homework(a). My professor ask me for implement a discrete pid controller in difference equation form to matlab function. This function block should run as a discrete pid controller block in simulink model(b). When simulation began, the Matlab function block is executed once. Because of for loop an array occurs. Then that array signal goes the plant. And this is not usefull. During the simulation what i want is every iteration of for loop gives a value and that value must go to plant. But i could not do this. The same issue happened previous homework(c). I don't even know whether this way is proper or not.

4 件のコメント
Alvery
2020 年 12 月 15 日
Think of your function as only solving a single step - it takes the current input, applies the difference function just once to it, and then produces the next result. This leaves you with a challenge - in order to make the difference function work, you also need to know the previous value that was computed.
How do you do memory? you can either store it externally (i.e. not in Matlab code, but in a separate Simulink block) in a 1/Z block, or you can store it internally in the Matlab. Internal storage is easy if you cheat - using 'persistent' variables, but this hides the memory from the solver which potentially messes up backtracking behaviour if your solver setting uses it. The correct alternative is to use stored state.
Sezer Memis
2020 年 12 月 16 日
Walter Roberson
2020 年 12 月 20 日
If you are using a discrete system then use https://www.mathworks.com/help/simulink/slref/memory.html memory block.
If you are using a continuous system, then you would have difficulty implementing something like the trapazoid rule.
Paul
2020 年 12 月 20 日
Hard to say how to make the two equivalent without knowing exactly what's inside the block C(s)1.
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Classical Control Design についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!





