What is the code used by controller blocks?

Hi all
I want to use the Discrete PID Controller or Discrete PID Controller (2DOF) blocks in m-file.
If the two following pictures represent the formula of the two blocks respectively:
picture1
picture2
What is the code of them?

回答 (1 件)

Arkadiy Turevskiy
Arkadiy Turevskiy 2014 年 10 月 15 日

0 投票

You cannot use Simulink blocks in a MATLAB file. You can use the blocks to create a Simulink model. You can then simulate the model by pressing the "run" button or by using sim command.
If that is not what the question was about, you need to formulate the question more clearly.
HTH

5 件のコメント

israa
israa 2014 年 10 月 15 日
Thanks for your response, my question is not how to run a block within m-file. I use a special block from a matlab-based toolbox which initialized by calling a function,so I want those controllers to be written as a function.
Such as for p-only controller:
function [output]=Pcontroller (setpoint,measurement)
output=Kp*(setpoint-measurement);
end
Arkadiy Turevskiy
Arkadiy Turevskiy 2014 年 10 月 16 日
I still do not understand the question. Are you asking how to write MATLAB code implementing PID controllers?
israa
israa 2014 年 10 月 17 日
編集済み: israa 2014 年 10 月 17 日
Yes I want a matlab code for discrete PID & 2DOF-PID controllers, but not as a transfer function..
Arkadiy Turevskiy
Arkadiy Turevskiy 2014 年 10 月 17 日
編集済み: Arkadiy Turevskiy 2014 年 10 月 17 日
We provide objects pid and pidstd for modeling PID controllers in MATLAB.
These objects are just like other LTI objects, such as transfer functions, and state space systems. You can uses them to create arbitrary feedback loops using commands such as connect and feedback, and then analyze resulting loops in time and frequency domains using commands such as step and bode .
If that is not what you need, you need to write your own MATLAB code to do what you want. You might want to search through MATLAB File Exchange to see if that has already been done by others.
israa
israa 2014 年 10 月 18 日
Ok thanks,yeah i know about pid and pidstd but I can't use them because as I mentioned i'm using a matlab-based toolbox (i.e special s-functions) I will search more in matlab file exchange.
Best regards

サインインしてコメントする。

カテゴリ

質問済み:

2014 年 10 月 15 日

コメント済み:

2014 年 10 月 18 日

Community Treasure Hunt

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

Start Hunting!

Translated by