MATLAB: How to transmit parameters to PID controller in simulink

externalpidsimulink

My PID parameter value Kp, Ki, Kd has to be calculated through other port in my simulink graph, but I don't know how to achieve this.
I saw this picture in Mathworks:
And I think it may work, but I don't know how to set the PID controller in libraries becomes like this. Thank you for taking time to read my question.

Best Answer

Configuring the PID Controller block in this way is new to R2015a, so if you have an earlier version you won't be able to do this. If you are on R2015a or R2015b, there should be a "Source" menu in the block dialog which you can change to external.
If you're on an earlier version, you can still implement this yourself. Right-click the PID Controller block and select "Mask > Look Under Mask". This will show you how the block is implemented, so you can replicate that diagram and replace all the Gain blocks with Product blocks, one of the inputs being a port to an external output.
- Sebastian
Related Question