Control Tutorials for MATLAB and Simulink (2024)

Key MATLAB commands used in this tutorial are: tf , conv , bode , margin , feedback , step

Related Tutorial Links

  • Intro to Freq Resp
  • Freq Resp Activity
  • Lead/Lag Freq Resp

Related External Links

Contents

  • Plotting the frequency response in MATLAB
  • Adding lead control
  • Plotting the closed-loop response

From the main problem, the dynamic equations in transfer function form are the following:

(1)Control Tutorials for MATLAB and Simulink (1)

(2)Control Tutorials for MATLAB and Simulink (2)

where,

(3)Control Tutorials for MATLAB and Simulink (3)

and the system schematic is the following where F(s)G1(s) = G2(s).

Control Tutorials for MATLAB and Simulink (4)

For the original problem and the derivation of the above equations and schematic, please refer to the Suspension: System Modeling page.

We want to design a feedback controller so that when the road disturbance (W) is simulated by a unit step input, the output (X1-X2) has a settling time less than 5 seconds and an overshoot less than 5%. For example, when the bus runs onto a 10-cm step, the bus body will oscillate within a range of +/- 5 mm and will stop oscillating within 5 seconds.

The system model can be represented in MATLAB by creating a new m-file and entering the following commands (refer to the main problem for the details of getting those commands).

m1 = 2500;m2 = 320;k1 = 80000;k2 = 500000;b1 = 350;b2 = 15020;nump=[(m1+m2) b2 k2];denp=[(m1*m2) (m1*(b1+b2))+(m2*b1) (m1*(k1+k2))+(m2*k1)+(b1*b2) (b1*k2)+(b2*k1) k1*k2];G1=tf(nump,denp);num1=[-(m1*b2) -(m1*k2) 0 0];den1=[(m1*m2) (m1*(b1+b2))+(m2*b1) (m1*(k1+k2))+(m2*k1)+(b1*b2) (b1*k2)+(b2*k1) k1*k2];G2=tf(num1,den1);numf=num1;denf=nump;F=tf(numf,denf);

Plotting the frequency response in MATLAB

The main idea of frequency-based design is to use the Bode plot of the open-loop transfer function to estimate the closed-loop response. Adding a controller to the system changes the open-loop Bode plot so that the closed-loop response will also change. Let's first draw the Bode plot for the original open-loop transfer function. Add the following line of code to your m-file and rerun. You should get the following Bode plot:

w = logspace(-1,2);bode(G1,w)

Control Tutorials for MATLAB and Simulink (5)

For convenience in representing systems with different natural frequencies of the system, we normalize and scale our findings before plotting the Bode plot, so that the low-frequency asymptote of each term is at 0 dB. This normalization by adjusting the gain, Control Tutorials for MATLAB and Simulink (6), makes it easier to add the components of the Bode plot. The effect of Control Tutorials for MATLAB and Simulink (7) is to move the magnitude curve up (increasing Control Tutorials for MATLAB and Simulink (8)) or down (decreasing Control Tutorials for MATLAB and Simulink (9)) by an amount Control Tutorials for MATLAB and Simulink (10), but the gain, Control Tutorials for MATLAB and Simulink (11), has no effect on the phase curve. Therefore from the previous plot, Control Tutorials for MATLAB and Simulink (12) must be equal to 100 dB or 100,000 to move the magnitude curve up to 0 dB at 0.1 rad/s. Go back to your m-file and add the following line of code to your m-file before the bode command and rerun. You should get the following Bode plot:

K=100000;bode(K*G1,w)

Control Tutorials for MATLAB and Simulink (13)

Adding lead control

From the Bode plot above, we see that the phase curve is concave at about 5 rad/sec. First, we will try to add positive phase around this region, so that the phase will remain above the -180 degree line. Since a large phase margin leads to a small overshoot, we will want to add at least 140 degrees of positive phase at the area near 5 rad/sec. Since one lead controller can add no more than +90 degrees, we will use a two-lead controller.

To obtain Control Tutorials for MATLAB and Simulink (14) and Control Tutorials for MATLAB and Simulink (15), the following steps can be used:

1. Determine the positive phase needed: Since we want 140 degrees total, we will need 70 degrees from each controller.

2. Determine the frequency where the phase should be added: In our case this frequency should be 5.0 rad/sec.

3. Determine the constant a from the equation below: This determines the required space between the zero and the pole for the desired maximum phase added.

(4)Control Tutorials for MATLAB and Simulink (16)

4. Determine Control Tutorials for MATLAB and Simulink (17) and Control Tutorials for MATLAB and Simulink (18) from the following equation: These determine the corner frequencies so that the maximum phase will be added at the desired frequency.

(5)Control Tutorials for MATLAB and Simulink (19)

(6)Control Tutorials for MATLAB and Simulink (20)

Now let's put our 2-lead controller into the system and see what the Bode plot looks like. Add the following code to your m-file, and add a % in front of the previous bode command (if there is one). You should get the following Bode plot:

a = (1-sin(70/180*pi))/(1+sin(70/180*pi));w=5;T=1/(w*sqrt(a));aT=sqrt(a)/w;numc = conv([T 1], [T 1]);denc = conv([aT 1], [aT 1]);C = tf(numc,denc);margin(K*C*G1)

Control Tutorials for MATLAB and Simulink (21)

From this plot we see that the concave portion of the phase plot is above -180 degrees now, and the phase margin is large enough for the design criteria. Let's see how the output (the distance X1-X2) responds to a bump on the road (W). Recall that the schematic of the system is:

Control Tutorials for MATLAB and Simulink (22)

and the closed-loop transfer function can be derived as follows:

sys_cl = F*feedback(G1,K*C);

Plotting the closed-loop response

Let's see what the step response looks like now. Keep in mind that we are using a 0.1-m step as the disturbance. To simulate this, simply multiply the system by 0.1. Add the following code into the m-file and rerun it. Don't forget to put % mark in front of all bode and margin commands!

t=0:0.01:5;step(0.1*sys_cl,t)axis([0 5 -.01 .01])

Control Tutorials for MATLAB and Simulink (23)

The amplitude of response is a lot smaller than the percent overshoot requirement and the settling time also is less than 5 seconds. Since we can see that an amplitude of the output's response less than 0.0001 m or 1% of input magnitude after 4 seconds. Therefore we can say that the settling time is 4 seconds from the above plot. From the Bode plot above, we see that increasing the gain will increase the crossover frequency and thus make the response faster. We will increase the gain and see if we can get a better response. Go back to your m-file and change numc as shown below to generate the following plot.

numc = 4*conv([T 1], [T 1]);denc = conv([aT 1], [aT 1]);C = tf(numc,denc);sys_cl = F*feedback(G1,K*C);t=0:0.01:5;step(0.1*sys_cl,t)axis([0 5 -.01 .01])

Control Tutorials for MATLAB and Simulink (24)

From this plot we can see that the percent overshoot is about 0.15 mm less than the previous plot's and the settling time is also less than 5 seconds. This response is now satisfactory and no more design iteration is needed.


Published with MATLAB® 9.2

Control Tutorials for MATLAB and Simulink (2024)

FAQs

Is MATLAB Simulink hard to learn? ›

Although Matlab is not considered to be a programming language, it really is easy to learn. When you write code on Matlab you actually don't care about declaring data types, allocating memories e.t.c like you do in other programming languages.

How much time does it take to learn Simulink? ›

Learn MATLAB and SIMULINK in one week

Ideal for beginners from any field, it covers vectors, matrices, loops, and functions.

Which engineers use MATLAB the most? ›

Mechanical engineers of Design and manufacturing field use MATLAB and Simulink heavily.

How long does it take to be proficient in MATLAB? ›

If you're a novice programmer, you can expect it to take a little longer than if you were a more seasoned programmer. Someone who can afford to devote all their time to MATLAB can finish learning the language in two weeks. If you have a lot of other responsibilities, however, it will take you longer to complete.

Is MATLAB harder than Python? ›

Learning curve: Python is significantly simpler than Matlab and doesn't require as much background knowledge. Matlab is structured in a very logical and comprehensible way but is aimed at users with a deep knowledge of math.

What is the salary of MATLAB Simulink engineer? ›

Matlab Simulink Developer salary in India ranges between ₹ 2.9 Lakhs to ₹ 15.0 Lakhs with an average annual salary of ₹ 5.5 Lakhs. Salary estimates are based on 46 latest salaries received from Matlab Simulink Developers. 1 - 4 years exp.

Does NASA use Simulink? ›

NASA Marshall Engineers have developed an ADCS Simulink simulation to be used as a component for the flight software of a satellite. This generated code can be used for carrying out Hardware in the loop testing of components for a satellite in a convenient manner with easily tunable parameters.

What is the disadvantage of Simulink? ›

Simulink's drawback lies in its confinement to pre-existing block functionalities, potentially limiting specific needs or requiring adjustments that might not align with desired behaviors or appearances.

Is MATLAB harder than Java? ›

Ease of Use and Learning Curve: Java has a steeper learning curve compared to MATLAB. It requires a good understanding of object-oriented programming concepts, data structures, and algorithms. MATLAB, on the other hand, has a more straightforward syntax and is more accessible for beginners.

Does NASA use MATLAB? ›

The team at NASA Ames worked with NASA's Johnson Space Center in Houston to install MATLAB, Simulink, and related products on laptops aboard the space station. MATLAB and Simulink passed a rigorous security, performance, and reliability review, and their use on the space station was approved.

Is there anything better than MATLAB? ›

Python, together with NumPy (numerical Python) and Matplotlib is an excellent replacement for Matlab. It won't run m-files, but the idea (matrix calculation and plotting) is very similar to Matlab.

Is MATLAB in high demand? ›

High Demand: Employers across industries, including engineering, finance, and research, actively seek skilled MATLAB professionals.

Is MATLAB enough for a job? ›

Conclusion. The industry has some familiar buzz that learning MATLAB will not be a good opportunity for a better career. But this is not fully true. Yes, it is an acceptable reason that salary or company structure will never be able to touch available popular jobs on other programming technologies.

Can I learn MATLAB on my own? ›

MATLAB's official website provides comprehensive resources, including documentation, tutorials, and examples. The MATLAB documentation covers all aspects of the language and its various toolboxes. It's an excellent starting point for learning MATLAB from scratch.

How much does it cost to get MATLAB certified? ›

Upcoming Certification Exams
DatesCertification ExamPrice
22 Oct 2024MathWorks Certified MATLAB Professional ExamUSD 800
14 Nov 2024MathWorks Certified MATLAB Professional ExamUSD 800
10 Dec 2024MathWorks Certified MATLAB Professional ExamUSD 800

How to learn MATLAB Simulink? ›

Start learning MATLAB and Simulink with free tutorials. Expand your knowledge through interactive courses, explore documentation and code examples, or watch how-to videos on product capabilities. Note: You must be on a desktop computer to take courses.

Is Simulink better than MATLAB? ›

Another factor to consider when choosing between Simulink blocks and MATLAB code is the speed and efficiency of your system. Simulink blocks can be faster and more efficient for some tasks, such as prototyping, testing, and debugging.

Is MATLAB easy to learn for beginners? ›

MATLAB® creates an environment where issues and resolutions are expressed in familiar mathematical notation. MATLAB® is not hard to learn if you go for any professional course. It is ideal for engineering graduates and IT professionals willing to develop MATLAB® skills in their related fields.

Is Simulink worth it? ›

Simulink is one of the most effective block diagram environment for modelling, simulation, and analysis of diverse systems. It is an intuitive tool that is very simple to understand.

Top Articles
2024 NFL preseason: How to watch the Philadelphia Eagles vs. New England Patriots game tonight
Tinyzonetv.to Unblocked
No Hard Feelings Showtimes Near Metropolitan Fiesta 5 Theatre
Section 4Rs Dodger Stadium
Chatiw.ib
Cash4Life Maryland Winning Numbers
Slapstick Sound Effect Crossword
Top Golf 3000 Clubs
123 Movies Black Adam
Scholarships | New Mexico State University
Grab this ice cream maker while it's discounted in Walmart's sale | Digital Trends
Blackwolf Run Pro Shop
Epro Warrant Search
Vistatech Quadcopter Drone With Camera Reviews
Milspec Mojo Bio
Kountry Pumpkin 29
Indystar Obits
Shiftselect Carolinas
Wemod Vampire Survivors
All Obituaries | Gateway-Forest Lawn Funeral Home | Lake City FL funeral home and cremation Lake City FL funeral home and cremation
Shadbase Get Out Of Jail
Costco Gas Hours St Cloud Mn
Aspenx2 Newburyport
Horn Rank
Phantom Fireworks Of Delaware Watergap Photos
Geico Car Insurance Review 2024
12657 Uline Way Kenosha Wi
Babydepot Registry
Funky Town Gore Cartel Video
Mastering Serpentine Belt Replacement: A Step-by-Step Guide | The Motor Guy
South Florida residents must earn more than $100,000 to avoid being 'rent burdened'
P3P Orthrus With Dodge Slash
Craigslist Red Wing Mn
Montrose Colorado Sheriff's Department
Vision Source: Premier Network of Independent Optometrists
Jason Brewer Leaving Fox 25
Miracle Shoes Ff6
Gravel Racing
Electric Toothbrush Feature Crossword
Nina Flowers
Arcane Bloodline Pathfinder
Is Ameriprise A Pyramid Scheme
Nu Carnival Scenes
Spreading Unverified Info Crossword Clue
Whitney Wisconsin 2022
Aloha Kitchen Florence Menu
Graduation Requirements
bot .com Project by super soph
Premiumbukkake Tour
The Jazz Scene: Queen Clarinet: Interview with Doreen Ketchens – International Clarinet Association
Bedbathandbeyond Flemington Nj
Diesel Technician/Mechanic III - Entry Level - transportation - job employment - craigslist
Latest Posts
Article information

Author: Fredrick Kertzmann

Last Updated:

Views: 5277

Rating: 4.6 / 5 (66 voted)

Reviews: 89% of readers found this page helpful

Author information

Name: Fredrick Kertzmann

Birthday: 2000-04-29

Address: Apt. 203 613 Huels Gateway, Ralphtown, LA 40204

Phone: +2135150832870

Job: Regional Design Producer

Hobby: Nordic skating, Lacemaking, Mountain biking, Rowing, Gardening, Water sports, role-playing games

Introduction: My name is Fredrick Kertzmann, I am a gleaming, encouraging, inexpensive, thankful, tender, quaint, precious person who loves writing and wants to share my knowledge and understanding with you.