Control Tutorials for MATLAB and Simulink (2024)

Related Tutorial Links

  • Simulink Control Intro
  • Simulink/MATLAB Interaction
  • Control Activity

Related External Links

Contents

  • Extracting a linear model into MATLAB
  • Implementing PI control
  • Closed-loop response

In the Cruise Control: Simulink Modeling page we created a Simulink model of the cruise control system. You can recreate the model or download it by right-clicking here and selecting Save link as. In this section, we will show how to implement a feedback controller in Simulink to meet the performance specifications for the system.

Extracting a linear model into MATLAB

A linear model of the system (in state space or transfer function form) can be extracted from a Simulink model into MATLAB. This is done through the use of In1 and Out1 blocks and the MATLAB function linmod.

  • Replace the Step Block and Scope Block with an In1 and an Out1 block, respectively (these blocks can be found in the Ports & Subsystems library). This defines the input and output of the system for the extraction process.

Control Tutorials for MATLAB and Simulink (1)

Save your file as "ccmodel.slx" (select Save As from the File menu). MATLAB will extract the linear model from the saved model file, not from the open model window. At the MATLAB prompt, enter the following commands:

m = 1000;b = 50;u = 500;[A,B,C,D] = linmod('ccmodel')cruise_ss = ss(A,B,C,D);
A = -0.0500B = 1.0000e-03C = 1D = 0

To verify the model extraction, we will generate an open-loop step response of the extracted transfer function in MATLAB. We will multiply the numerator by 500 to simulate a step input of 500 N. Enter the following command in MATLAB.

step(u*cruise_ss)

Control Tutorials for MATLAB and Simulink (2)

Implementing PI control

In the Cruise Control: PID Control page a PI controller was designed with Control Tutorials for MATLAB and Simulink (3) and Control Tutorials for MATLAB and Simulink (4) to give the desired response. We will implement this in Simulink by first containing the open-loop system from earlier in this page in a Subsystem block.

  • Create a new model window.
  • Drag a Subsystem block from the Ports & Subsystems library into your new model window.

Control Tutorials for MATLAB and Simulink (5)

  • Double-click on this block. You will see a blank window representing the contents of the subsystem (which is currently empty).
  • Open your previously saved model of the cruise control system, ccmodel.slx.
  • Select Select All from the Edit menu (or Ctrl-A), and select Copy from the Edit menu (or Ctrl-C).
  • Select the blank subsystem window from your new model and select Paste from the Edit menu (or Ctrl-V). You should see your original system in this new subsystem window. Close this window.
  • You should now see input and output terminals on the Subsystem block. Name this block "plant model".

Control Tutorials for MATLAB and Simulink (6)

Now, we will build a PI controller around the plant model. First, we will feed back the plant output.

  • Draw a line extending from the plant output.
  • Insert a Sum block and assign "+-" to it's inputs.
  • Tap a line of the output line and draw it to the negative input of the Sum block.

Control Tutorials for MATLAB and Simulink (7)

The output of the Sum block will provide the error signal. From this, we will generate proportional and integral components.

  • Insert an Integrator block after the Sum block and connect them with a line.
  • Insert and connect a Gain block after the Integrator block to provide the integral gain.
  • Label this Integrator "Ki" and assign it a value of "Ki".
  • Insert a new Gain block and connect it with a line tapped off the output of the Sum block.
  • Label this gain "Kp" and assign it a value of "Kp".

Control Tutorials for MATLAB and Simulink (8)

Now we will add the proportional and integral components and apply the sum to the plant.

  • Insert a Sum block between the Ki block and the plant model and connect the outputs of the two Gain blocks to the Sum block inputs.
  • Connect the Sum block output to the input of the plant block.

Control Tutorials for MATLAB and Simulink (9)

Finally, we will apply a step input and view the output with a Scope block.

  • Attach a Step block to the free input of the feedback Sum block.
  • Attach a Scope block to the plant output.
  • Double-click the Step block and set the Step Time to "0" and the Final Value to "u". This allows the input magnitude to be changed outside of Simulink.

Control Tutorials for MATLAB and Simulink (10)

You can download our version of the closed-loop system model by right-clicking here and selecting Save link as.

In this example, we constructed a PI controller from fundamental blocks. As an alternative, we could have used a Transfer Function block (from the Continuous library) to implement this in one step, as shown below.

Control Tutorials for MATLAB and Simulink (11)

You can download this model by right-clicking here and selecting Save link as.

Closed-loop response

To simulate this system, first, an appropriate simulation time must be set. Select Parameters from the Simulation menu and enter "10" in the Stop Time field. The design requirements included a rise time of less than 5 sec, so we simulate for 10 seconds to view the output. The physical parameters must now be set. Run the following commands at the MATLAB prompt:

m = 1000;b = 50;r = 10;Kp = 800;Ki = 40;

Run the simulation (hit Ctrl-T or select Run from the Simulation menu). When the simulation is finished, you should see the following output.

Control Tutorials for MATLAB and Simulink (12)


Published with MATLAB® 9.2

Control Tutorials for MATLAB and Simulink (2024)

FAQs

How is MATLAB used in control systems? ›

Using MATLAB and Simulink control systems products, you can: Model linear and nonlinear plant dynamics using basic models, system identification, or automatic parameter estimation. Trim, linearize, and compute frequency response for nonlinear Simulink models.

Where can I learn MATLAB Simulink? ›

  • MathWorks. Robotics Education - MATLAB and Simulink Robotics Arena. ...
  • MathWorks. Mechatronics with MATLAB and Simulink. ...
  • MathWorks. Simulink Onramp. ...
  • MATLAB/Simulink for the Absolute Beginner. 1894 ratings at Udemy. ...
  • Learn MATLAB and SIMULINK in one week. 559 ratings at Udemy. ...
  • IIT Roorkee; NPTEL. ...
  • MATLAB and SIMULINK. ...
  • MathWorks.

What is control model in Simulink? ›

Simulink Control Design lets you design and analyze control systems modeled in Simulink. You can automatically tune arbitrary SISO and MIMO control architectures, including PID controllers. PID autotuning can be deployed to embedded software for automatically computing PID gains in real time.

What is the basics of Simulink in MATLAB? ›

Simulink is a graphical extension to MATLAB for modeling and simulation of systems. One of the main advantages of Simulink is the ability to model a nonlinear system, which a transfer function is unable to do. Another advantage of Simulink is the ability to take on initial conditions.

What is MATLAB control system toolbox? ›

Control System Toolbox provides algorithms and apps for systematically analyzing, designing, and tuning linear control systems.

Why is MATLAB so widely used? ›

Algorithm Development: MATLAB is widely used for developing and implementing algorithms. It provides a convenient environment for prototyping, testing, and refining algorithms before deploying them in real-world applications.

Why use Simulink instead of 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.

What is the Python equivalent of MATLAB Simulink? ›

BMS is designed as a lightweight, fully scriptable, open-source equivalent to simulink in python.

What companies use MATLAB Simulink? ›

Companies Currently Using Simulink
Company NameWebsiteHQ Address
Northrop Grummannorthropgrumman.com2980 Fairview Park Dr
General Motorsgm.com300 Renaissance Ctr Ste L1
Ford Motor Companyford.comOne American Rd. 4th Floor
Harris Corporationl3harris.com1025 W. NASA Blvd
2 more rows

How to design a controller in MATLAB Simulink? ›

To design a controller, first select the controller sample time and horizons, and specify any required constraints. For more information, see Choose Sample Time and Horizons and Specify Constraints. You can then adjust the controller weights to achieve your desired performance. See Tune Weights for more information.

How to create a model in Simulink? ›

Create a Simulink Model
  1. In the MATLAB® Home tab, click the Simulink button.
  2. Click Blank Model, and then Create Model. ...
  3. On the Simulation tab, click Library Browser.
  4. In the Library Browser: ...
  5. Make the following block-to-block connections: ...
  6. Double-click the Transfer Fcn block. ...
  7. Double-click the Signal Generator block.

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 do I start Simulink in MATLAB? ›

You start Simulink by clicking the Simulink button in the MATLAB toolstrip. This opens the Start Page, where you can create new models, find examples, and even find basic training. We're starting our model from scratch, so we'll choose Blank Model. Simulink models are built up from blocks and signals.

What is MATLAB commonly used for? ›

MATLAB® is a programming platform designed specifically for engineers and scientists to analyze and design systems and products that transform our world. The heart of MATLAB is the MATLAB language, a matrix-based language allowing the most natural expression of computational mathematics.

What is the use of MATLAB in power system? ›

Scientists and engineers use MATLAB and Simulink to perform power system studies and coordination analysis, design power system equipment, and develop control algorithms. With MATLAB and Simulink, you can: Perform system feasibility and grid integration studies using prebuilt functions and apps.

What is the use of MATLAB in electronics? ›

Power electronics engineers use MATLAB and Simulink to develop digital control systems for motors, power converters, and battery systems. MATLAB and Simulink offer: A multi-domain block diagram environment for modeling plant dynamics, designing control algorithms, and running closed-loop simulations.

Which MATLAB allows modelling of different control systems using? ›

Explanation: Simulink is a separate package which is present in MATLAB. It helps to model and analyze a control system which makes MATLAB a very powerful tool for simulating dynamic systems.

References

Top Articles
Top 10 Best Planet Zoo Mods & How to Install Them
The 25 Best Mods For Planet Zoo (All Free) – FandomSpot
Spasa Parish
Rentals for rent in Maastricht
159R Bus Schedule Pdf
Sallisaw Bin Store
Black Adam Showtimes Near Maya Cinemas Delano
5daysON | Hoofddorp (70089000)
Espn Transfer Portal Basketball
Pollen Levels Richmond
11 Best Sites Like The Chive For Funny Pictures and Memes
Xenia Canary Dragon Age Origins
Momokun Leaked Controversy - Champion Magazine - Online Magazine
‘An affront to the memories of British sailors’: the lies that sank Hollywood’s sub thriller U-571
Tyreek Hill admits some regrets but calls for officer who restrained him to be fired | CNN
Haverhill, MA Obituaries | Driscoll Funeral Home and Cremation Service
Ems Isd Skyward Family Access
Sauce 423405
Elektrische Arbeit W (Kilowattstunden kWh Strompreis Berechnen Berechnung)
Omni Id Portal Waconia
Kellifans.com
Banned in NYC: Airbnb One Year Later
Four-Legged Friday: Meet Tuscaloosa's Adoptable All-Stars Cub & Pickle
Model Center Jasmin
Ice Dodo Unblocked 76
Is Slatt Offensive
Labcorp Locations Near Me
Storm Prediction Center Convective Outlook
Experience the Convenience of Po Box 790010 St Louis Mo
Fungal Symbiote Terraria
modelo julia - PLAYBOARD
Abby's Caribbean Cafe
Joanna Gaines Reveals Who Bought the 'Fixer Upper' Lake House and Her Favorite Features of the Milestone Project
Tri-State Dog Racing Results
Trade Chart Dave Richard
Lincoln Financial Field Section 110
Free Stuff Craigslist Roanoke Va
Stellaris Resolution
Wi Dept Of Regulation & Licensing
Pick N Pull Near Me [Locator Map + Guide + FAQ]
Horseheads Schooltool
Crystal Westbrooks Nipple
Ice Hockey Dboard
Über 60 Prozent Rabatt auf E-Bikes: Aldi reduziert sämtliche Pedelecs stark im Preis - nur noch für kurze Zeit
Wie blocke ich einen Bot aus Boardman/USA - sellerforum.de
Craigslist Pets Inland Empire
Infinity Pool Showtimes Near Maya Cinemas Bakersfield
Hooda Math—Games, Features, and Benefits — Mashup Math
How To Use Price Chopper Points At Quiktrip
Maria Butina Bikini
Busted Newspaper Zapata Tx
Latest Posts
Article information

Author: Zonia Mosciski DO

Last Updated:

Views: 6185

Rating: 4 / 5 (71 voted)

Reviews: 94% of readers found this page helpful

Author information

Name: Zonia Mosciski DO

Birthday: 1996-05-16

Address: Suite 228 919 Deana Ford, Lake Meridithberg, NE 60017-4257

Phone: +2613987384138

Job: Chief Retail Officer

Hobby: Tai chi, Dowsing, Poi, Letterboxing, Watching movies, Video gaming, Singing

Introduction: My name is Zonia Mosciski DO, I am a enchanting, joyous, lovely, successful, hilarious, tender, outstanding person who loves writing and wants to share my knowledge and understanding with you.