View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from
Learning PID Tuning III: Performance Index Optimization

4.5 | 4 ratings Rate this file 64 Downloads (last 30 days) File Size: 41.6 KB File ID: #18674 Version: 1.0
image thumbnail

Learning PID Tuning III: Performance Index Optimization


Yi Cao (view profile)


08 Feb 2008 (Updated )

A tool and tutorial to perform optimal PID tuning

| Watch this File

File Information

Most PID tuning rules are based on first-order plus time delay assumption of the plant hence cannot ensure the best control performance. Using mordern optimization techniques, it is possible to tune a PID controller based on the actual transfer function of the plant to optimize the closed-loop performance.

This submission contains a function to perform optimal PID design based on four different performance indices, e.g. the ISE, the IAE, the ITSE and the ITAE. A published m-file provides two 4th-order examples to explain the usage and to show impact of using different performance indices.

The example file requires the znpidtuning function, which can be downloaded from


Learning Pid Tuning I: Process Reaction Curve and Learning Pid Tuning Ii: Stability Margin inspired this file.

Required Products Control System Toolbox
Optimization Toolbox
MATLAB release MATLAB 7.5 (R2007b)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (9)
30 Mar 2015 Jagan kumar M

How to run this file. I got error like below.

Warning: Escape sequence '\U' is not valid. See 'help sprintf' for valid escape sequences.
> In DynamicSystem.margin at 48
In optimPID at 52
In optimalpidtuning at 44
Error using DynamicSystem/margin (line 48)
Error: optimPID (line 52)

Error in optimalpidtuning (line 44)
C1=optimPID(G,3,1); % PID-Control, ISE index

please help me i am new to matlab

Comment only
28 Aug 2014 Manoj

Manoj (view profile)

22 Jul 2014 Maria

Maria (view profile)

I tried using the optimPID function for a second-order system but I get the following error message: 'Error using fminusub (line 17)
Objective function is undefined at initial point. Fminunc cannot
Any help would be greatly appreciated.
Thank you.

Comment only
18 Dec 2012 Roberto Lopez

We have tried this powerful tool at a University in Ecuador, where I come from. We would like to include the code applied for the Transfer Function of our Engineering Graduation Project, respecting all what says in the licensing file. But we also would like to know if there is more information behind the "optimPID" function development, so we can also include it as a reference.
Thank you very much!

Comment only
18 Dec 2012 Roberto Lopez

18 Mar 2012 robert howrd

Why your program hangs when I do this?

EDU>> clear all
EDU>> s=tf('s');
EDU>> sys=1/(10*s^2+s+1);
EDU>> sys2=optimPID(sys,1,1)

it now hangs. I am using Matlab 2011a


Comment only
22 Dec 2009 Arkadiy Turevskiy

Thanks for an interesting submission. If you are interested in designing and tuning PID controllers in MATLAB and Simulink, please take a look at new PID tuning capabilities shipped in Simulink Control Design in R2009b:

There is also a webinar on the subject:

and MATLAB Digest article:

Comment only
05 Apr 2009 V. Poor

30 Mar 2008 AKIN YILMAZ

Contact us