File Exchange

image thumbnail

Inverted Pendulum

version (690 KB) by Khalil Sultan
A collection of MATLAB files, useful for analyzing inverted pendulum & designing controller for it.


Updated 09 Feb 2007

View License

The Inverted Pendulum; Analysis, Design & Implementation is a collection of MATLAB functions & scripts, and SIMULINK models, useful for analyzing Inverted Pendulum System and designing Control System for it.

The Inverted Pendulum is one of the most important classical problems of Control Engineering. Broom Balancing (Inverted Pendulum on a cart) is a well known example of nonlinear, unstable control problem. This problem becomes further complicated when a flexible broom, in place of a rigid broom, is employed. Degree of complexity and difficulty in its control increases with its flexibility. This problem has been a research interest of control engineers. In this submission, however, we have analyzed Inverted Pendulum only with rigid broom.

The aim of this study is to stabilize the Inverted Pendulum such that the position of the carriage on the track is controlled quickly and accurately so that the pendulum is always erected in its inverted position during such movements.

The inverted pendulum (IP) is among the most difficult systems to control in the field of control engineering. Due to its importance in the field of control engineering, it has been a task of choice to be assigned to Control Engineering students to analyze its model and propose a linear compensator according to the PID control law.

The work included in this submission has been carried out in the
Instrumentation and Control Lab at the Institute of Industrial Electronics Engineering, Karachi, Pakistan.

The author would like to thank Dr. Ken Dutton [School of Engineering, Sheffield Hallam University, UK; Author: "Art of Control Engineering"] for his review of this submission.

Cite As

Khalil Sultan (2020). Inverted Pendulum (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (51)

bob xia

good job!

good work...


i tried to design a swing up controller based on energy control.I just calculated the energy of pendulum and find maximum acceleration about the pivot and calculated the corresponding voltage signal and then feedback it to the system. But it won't produce correct results . I obtained graphs which is correct up to 0.325seconds after that the controlling is lost. Can you pls guide me?


Atif Anwer

Hi! I took a look on your paper work and I find it very interesting and complete. I had to develop a project about an Inverted Pendulum and this was very helpful.
However, when I put a scope on the PID law (ipcstep.mdl), I saw an infinite command (~2.2*exp15). I think this is the result of simplifying an unstable zero by introducing an integrator.
I would like to know your response; maybe I’m wrong, but I need your help for my project.
A million thanks,

timm maths

Excellent Work.

Hi, may I know if it is possible to keep the pendulum balanced at a desire angle from the vertical without the cart below going to infinity? Thank you.

Very Nice I've also used here
It's the Inverted Pendulum control simulation with SimMechanics in Simulink

Great Job - very detailed! I just want to mention something that seems a bit confusing. You state that the steady state error is zero in response to a unit step input, but the output is 0.35 rather than 1. The open loop transfer function is a type zero, which would not be able to render a zero steady state error in response to a step input. I was able to calculate a steady state error of 0.65, which leads to the output of 0.35. I'm certainly not an expert, and might be analyzing this incorrectly, but wanted to make note of it since the paper seems so complete otherwise.

Not Fake

Comprehensive, helpful, thorough. Excellent example.

Zaheer Mohammed

Muhammad Faisal

Very good work.Keep it up

Zaheer Ahmed

saad mubeen

salim awde

very important work

Ravi varma bhpathiraju

Nguyen Thanh Phuc


The over all assessment of the problem is good. The control of inverted pendulum using fuzzy systems is needed

anh duy

Sadid S.

I am a student in electronic
It was very useful for me as a good tutorial for Matlab Control and also my very elementary control learning course(Linear Control)
Thank you!

Thirunavukkarasu Indiran

It will be very usefull for the research peoples who want to validate their results in real time systems.

Ichiro Inui

I have some delusions and dissociations about Inverted Pendulum.
I developed new type Inverted Pendulum for gain-scheduling control theory in Japan.
If you have any intersts for this message please contuct me.

fatemeh darakeh

i want some file

srisuneel bhaskar

its very help full for beginners now i am doing the same by using model predictive control technique.if any body have suggestions please give me at

Sasa Milovanovic

Most complete paper on this subject!
Very good work!

Vishnuvenkatesh Dhage

phuc nguyen

Fabiano Souza

I can't open...error in acrobat.

Gledson Melotti

Hi Khalil Sultan, all good one. I found its site in the Internet and I liked it very content about controlling using matlab. By chance you have some you would materia on the controlled inverted pendulum for logic fuzzy.

I am thankful since already for the attention, Gledson Melotti.

Markos X

I want to ask u something. Supposing we have the pendulum at 0 degrees angle and we want to force it to go to 180 degrees angle. Can u help me write this code?

nil nil

i think u are not concidering the moment of inertia of the connector. it may be a significant factor if we are using a solid connector

MHB murshid

am doing a project in inverted pendulum so hope this might help me in anyways



Minh Thanh Phan

Dung cai toi dang tim

Florin Blaga

Ricardo Vecchio

davide rapicavoli

vikrant kumar


well wisher


ida saya

thank you.your paper have help me a lot.thank you very much.

Gary Rosende

Your paper is very good.

Chris Perkins

Good god that is fantastic!

Jeff G

As a Master's student in the US, hats off to the author! This is truly an excellent presentation.

I'd love to see it redone, though, using State-Space, and LQR techniques rather than Classical Design Theory!

Great write-up!

srikanth chinta

great help

Shanbin Li

A wonderful work! Thank you!

nima moshtagh

hosein sadeghi

Justin Alcorn

thank you, I'm started studying controls recently and that was very helpful on my education.


Change in description.

Change of category in MATLAB File Exchange, change in keywords, summary and description.

MATLAB Release Compatibility
Created with R13
Compatible with any release
Platform Compatibility
Windows macOS Linux