Control Tutorials for MATLAB and Simulink (2024)

Contents

  • Purpose
  • Running the GUI
  • Using the GUI

Purpose

The purpose of this Graphical User Interface (GUI) is to allow the user to view an animation of the ball and beam system with the step disturbance response plot. This allows the user to see the correlation between the plot and the system's physical response.

The animation and GUI are based on the example. This method was used because we can easily return the ball position and beam angle as well as their respective velocities. For more information on the system model please refer to the page.

Running the GUI

To run the GUI you will need 3 files. Copy each of them to the directory in which you are running MATLAB.

bbgui.fig - contains the graphical interface.

bbgui.m - contains the GUI callback function.

bbfunode.m - contains the ode file necessary to run the non-linear simulation.

Once these files are copied into your MATLAB directory, simply enter the following command:

bbgui

Neither of the other two files need to be run from the command window, they will be called separately by the GUI. The following figure should appear on your screen after the command has been executed:

Control Tutorials for MATLAB and Simulink (1)

Once you hit Run, you should be able to see the following figures.

Control Tutorials for MATLAB and Simulink (2)

Using the GUI

Below are descriptions of each of the controls found in the GUI. These descriptions are intended to give the user a better understanding of what each control actually does. However, feel free to experiment with the controls and use this section as a reference for any questions you might have.

The first group of controls contains the Run, Repeat, Reset and Exit buttons. These controls perform most of the work in the GUI.

Control Tutorials for MATLAB and Simulink (3)

Run - This button performs the simulation, plots the response in the upper-right portion of the window and runs the animation in the lower-right portion of the window.

Repeat - The purpose of this button is to re-plot the response and re-run the animation. It uses the results from the previous simulation performed by choosing the Run button. This is especially useful for the nonlinear simulation, which can take some time to run.

Reset - This button clears the upper-right step response plot and sets the ball position and beam angle to zero in the lower-right plot. If a plot is not cleared, the next run will be graphed on the same plot. This is useful if you want to graphically see the effect of varying a parameter.

Exit - This button closes the GUI.

An example of the animation and response plot are shown below.

Control Tutorials for MATLAB and Simulink (4)

The next group of controls allows the user to place the system's four poles wherever desired. This is the input to the design of the full-state feedback controller.

Control Tutorials for MATLAB and Simulink (5)

Complex Poles - The two side-by-side editable text fields allow you to position poles in the imaginary plane. The first field represents the real part and should stay negative (a positive real pole will lead to an unstable closed-loop system). The second field contains the imaginary part. The +/- between them indicates that these are two poles in a complex conjugate pair. Making the real part more negative will decrease response time, while increasing the imaginary part will increase the overshoot.

Real Poles - The bottom two editable text fields contain the real poles which can be placed anywhere on the real axis. These poles are usually placed far to the left so that the complex poles will dominate the response.

Feel free to move the poles around to see what happens!

The control shown below allows you to change the step input command.

Control Tutorials for MATLAB and Simulink (6)

Step Slider - The slider allows you to change the magnitude of the step input command. You can click on the arrows to move the slider, grab the the slider bar and move it, or click on the slider to change the step input. The current value of the step input is displayed in the upper portion of the box.

This next group of controls contains checkboxes that allow the user to change various features of the GUI.

Control Tutorials for MATLAB and Simulink (7)

Manual Advance - If this control is checked, the user is able to advance the animation and plot one frame at a time. The frames are advanced by pressing any key on the keyboard. This function is useful if the animation moves too fast for the user and will allow the user to better visualize the entirety of the system's motion.

Plot Separately - By checking this box the step response plot is graphed in its entirety before the animation is run.

Reference Input - This box is automatically checked when the GUI is run. By un-checking it the user removes the reference input term, Nbar, from the simulation. The reference input is used to correct steady-state errors common to full-state feedback systems.

Non-Linear System - This checkbox allows the user to switch the model from the linear representation used throughout the tutorials to the full nonlinear representation of the system. Through the nonlinear system the user may get a better idea of what actually happens in the system. For instance, the linear representation will allow the ball to move faster than is physically possible when seen in the nonlinear system.

Remember, this GUI is intended to be an interactive learning tool that will allow the user to get a feeling for how some basic control techniques and ideas are represented in the real world. Therefore, the user is encouraged to play around with this tool to enhance their understanding of controls.


Published with MATLAB® 9.2

Control Tutorials for MATLAB and Simulink (2024)

FAQs

How do I find answers in MATLAB? ›

To view all of your solutions, go to a Problem page and click View my solutions. You can view your solutions in a list or in the Solution Map. If using the list view, you can review the display by selecting a Sort by option.

Is MATLAB Simulink hard to learn? ›

Is MATLAB Hard to Learn? MATLAB is designed for the way you think and the work you do, so learning is accessible whether you are a novice or an expert. The Help Center is always available to guide you with robust documentation, community answers, and how-to videos.

How much time is required to learn 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.

How do you get a long answer in MATLAB? ›

To format the way numbers display, do one of the following:
  1. On the Home tab, in the Environment section, click Preferences. Select MATLAB > Command Window, and then choose a Numeric format option.
  2. Use the format function, for example: format short format short e format long.

How do I find Solver in MATLAB? ›

Description. S = solve( eqn , var ) solves the equation eqn for the variable var . If you do not specify var , the symvar function determines the variable to solve for. For example, solve(x + 1 == 2, x) solves the equation x + 1 = 2 for x.

Is MATLAB harder than Python? ›

The Difference in Technical Computing:

They are both used for the same type of work, such as numerical analysis, data visualization, and scientific computation. When it comes to syntax and readability, Python is often easier to read and understand than MATLAB.

What is the salary of MATLAB Simulink? ›

Average Annual Salary by Experience

Matlab Developer salary in India with less than 1 year of experience to 5 years ranges from ₹ 2.0 Lakhs to ₹ 9.4 Lakhs with an average annual salary of ₹ 5.6 Lakhs based on 342 latest salaries.

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.

What coding language is MATLAB most like? ›

Language Comparison

The language of Python and MATLAB can be used interactively (a single command at a time) or to develop large-scale applications.

Can I learn MATLAB on my own? ›

Get Started with Introductory Videos

See common applications and workflows, and discover new product capabilities. Get started with MATLAB by walking through an example. This video shows you the basics, and it gives you an idea of what working in MATLAB is like.

What should I know before learning MATLAB? ›

- [Instructor] Before taking this course, it would be helpful to have a basic understanding of programming concepts such as variables, conditional statements, functions, et cetera. Also, it would be beneficial to have some basic knowledge on linear algebra and calculus.

Is MATLAB in high demand? ›

Matlab careers are actually on the rise today. It's a very popular programming language. It can be used by a developer, engineer, programmer, scientist, etc. to collect and sort out data, and develop apps, software, and sites.

Can I learn MATLAB in 1 month? ›

If you want to become an expert in Matlab then you need to mention which part of madlab you want to learn and want expertise. If I generalize my answer highly, It may take at least 3 months to learn matlab and may take maximum 3 years to become an expert.

Is MATLAB beginner friendly? ›

MATLAB is beginner-friendly, so you can learn it even if you're new to programming.

How to check results in MATLAB? ›

View Results in Command Window

The Summary Report link provides access to the Model Advisor Command-Line Summary report. You can review additional results in the Command Window by calling the DisplayResults parameter when you run the Model Advisor.

How do you find the step response in MATLAB? ›

[ y , tOut ] = step( sys , tFinal ) computes the step response from t = 0 to the end time t = tFinal . [ y , tOut ] = step( sys , t ) returns the step response of a dynamic system model sys at the times specified in the vector t .

How do I find something in MATLAB code? ›

Search Using Find Dialog Box

The Find dialog box opens. The search begins at the current cursor position. MATLAB finds the text you specified and highlights it. MATLAB beeps when a search for Find Next reaches the end of the Command Window, or when a search for Find Previous reaches the top of the Command Window.

What is the ANS command in MATLAB? ›

ans is the variable created when an output is returned without a specified output argument. MATLAB® creates the ans variable and stores the output there. Changing or using the value of ans in a script or function is not recommended, as the value can change frequently. ans is specific to the current workspace.

References

Top Articles
Latest Posts
Article information

Author: Arline Emard IV

Last Updated:

Views: 6103

Rating: 4.1 / 5 (72 voted)

Reviews: 87% of readers found this page helpful

Author information

Name: Arline Emard IV

Birthday: 1996-07-10

Address: 8912 Hintz Shore, West Louie, AZ 69363-0747

Phone: +13454700762376

Job: Administration Technician

Hobby: Paintball, Horseback riding, Cycling, Running, Macrame, Playing musical instruments, Soapmaking

Introduction: My name is Arline Emard IV, I am a cheerful, gorgeous, colorful, joyous, excited, super, inquisitive person who loves writing and wants to share my knowledge and understanding with you.