how to use matlab for dynamical systems course

by Mr. Heber O'Hara 8 min read

How do I run a MATLAB program?

So far, we’ve run MATLAB by typing into the command window. This is OK for simple calculations, but usually it is better to type the list of commands you plan to execute into a file (called an M-file), and then tell MATLAB to run all the commands together.

What is MATLAB and how does it work?

You can think of MATLAB as a sort of graphing calculator on steroids – it is designed to help you manipulate very large sets of numbers quickly and with minimal programming. Operations on numbers can be done efficiently by storing them asmatrices.

How to create differential equations in MATLAB?

Create anm-fileas follows, and save it in a file called ‘simple_ode.m’ function dydt = simple_ode(t,y) % Example of a MATLAB differential equation function dydt = -10*y + sin(t); end It’s important to understand what this function is doing. Remember, (t,y)are the ‘input variables’ to the function. ‘dydt’ is the ‘output variable’.

Does MATLAB support d dt f Ty y/()  equations?

The equations we solve in dynamics usually involveaccelerations, and so don’t have the form d dt f ty y/ ( , ) required by MATLAB. Fortunately, a simple trick can be used to convert an equation involving accelerations into this form.

Why do we need MATLAB in EN40?

The main reason for learning MATLAB in EN40 is so you can use it to analyze motion of an engineeringsystem. To do this, you always need to solve a differential equation. MATLAB has powerful numericalmethods to solve differential equations. They are best illustrated by means of examples.

What is the solver for differential equations called?

The solver called ‘ode45’ is the basic MATLAB work-horse for solving differential equations. It worksfor most ODEs, but not all. MATLAB has many other choices if ‘ode45’ doesn’t work. Using them isvery similar to using ‘ode45’ but they are based on different numerical algorithms. You can learn a lotmore about MATLAB ODE solvers in the section of the manual shown below

Is Mathematica better than MATLAB?

They are similar in some ways, although they use vastly different languages. Mathematica is bettersuited to algebra ic calculations; MATLAB is better at numerical calculations and data processing. Butmost things that can be done in Mathematica can also be done in MATLAB, and vice-versa.

Does MATLAB have a pi?

If you have not already done so, use MATLAB to calculate >>sin(pi) The answer, of course, should be zero, but MATLAB returns a small, but finite, number. This is because MATLAB (and any other program) stores floating point numbers as sequences of binary digits with a finite length.

Course Materials Include

Professor Jenna Gorlewicz Department of Mechanical and Industrial Engineering Southern Illinois University

Teaching System Dynamics with Arduino, MATLAB, and Simulink

Professor Jenna Gorlewicz Department of Mechanical and Industrial Engineering Southern Illinois University

image