Presentation is loading. Please wait.

Presentation is loading. Please wait.

ME457 Mechatronic System Modeling MICHIGAN STATE UNIVERSITY Matlab® refresher Your objective: to dominate! My objective: to help you dominate!

Similar presentations


Presentation on theme: "ME457 Mechatronic System Modeling MICHIGAN STATE UNIVERSITY Matlab® refresher Your objective: to dominate! My objective: to help you dominate!"— Presentation transcript:

1 ME457 Mechatronic System Modeling MICHIGAN STATE UNIVERSITY Matlab® refresher Your objective: to dominate! My objective: to help you dominate!

2 ME457 Mechatronic System Modeling MICHIGAN STATE UNIVERSITY Some references MATLAB Student Version: Learning MATLAB, The MathWorks, Inc. Introduction to MATLAB 6 for Engineers, W.J.Palm III, McGraw-Hill. Numerical Methods with MATLAB, G.Recktenwald, Prentice Hall.

3 ME457 Mechatronic System Modeling MICHIGAN STATE UNIVERSITY Key concept: the Workspace (WS) The Workspace (WS) contains all of your currently active variables and relations. These are initially entered by typing commands (most likely). Useful Workspace commands: –Clear : empty the WS –Who (whos) : show what is in the WS –Save : save all WS variables to file –Load : retrieve a particular WS from file

4 ME457 Mechatronic System Modeling MICHIGAN STATE UNIVERSITY Key concept: WS inputs WORKSPACE

5 ME457 Mechatronic System Modeling MICHIGAN STATE UNIVERSITY Key concept: WS outputs WORKSPACE

6 ME457 Mechatronic System Modeling MICHIGAN STATE UNIVERSITY Script files Script files are text files that are created using the MATLAB script file editor. They usually have the suffix.m. A script file can be run from the command line or toolbar. Two items to remember about.m files: –Use “%” to enter comments for your use. –Use “;” at the end of lines to suppress echo printing when the file is run.

7 ME457 Mechatronic System Modeling MICHIGAN STATE UNIVERSITY More about the Workspace Recording your MATLAB session can be useful for documentation. Useful Workspace commands: –Diary : turn on recording of all text i/o except plots, save into –Diary off : turn off current recording –Path : pointer to current directory –Pathtool : directory browser

8 ME457 Mechatronic System Modeling MICHIGAN STATE UNIVERSITY A typical session pattern Clear Diary Problem1 { create data etc here …} –Pa= 14.7; R= 245.6; P= 23; Q = (1/R)*(P-Pa); –who Save Problem1Run1 Diary off You now have 2 files: Problem1: a diary of this session Problem1Run1: a WS file that can be used to recover your last state by using a Load command

9 ME457 Mechatronic System Modeling MICHIGAN STATE UNIVERSITY Solving Linear Algebraic Equations Define a set of linear algebraic equations as follows: A*X = B*U –X is the unknown vector (n x 1) –U is the input vector (m x 1) –A is n x n, B is n x m In the WS define A, B, and U. Then type X= inv(A)*B*U Click here to see an example session: LAExample1LAExample1

10 ME457 Mechatronic System Modeling MICHIGAN STATE UNIVERSITY Solving Linear Algebraic Equations Dominators know that a unique solution to a problem in linear algebra doesn’t always exist. To investigate before you leap try this: –Use the command det(A) to check the determinant of A. Proceed accordingly. Sometimes we seek insight in the form of eigenvalues of A. Try this: –Type Evals= eig(A). Click here to see an example session: LAExample2LAExample2

11 ME457 Mechatronic System Modeling MICHIGAN STATE UNIVERSITY Solving Linear Differential State Equations Define a set of linear algebraic equations: Xdot = A*X + B*U –Xdot is the first derivative of X. Create a script (.m) file that defines the equations for MATLAB in a specific format. –for example: LDEEqns1.m Create a script file that controls the solving of the problem. –click to see an example: LDEExample.pdfLDEExample.pdf


Download ppt "ME457 Mechatronic System Modeling MICHIGAN STATE UNIVERSITY Matlab® refresher Your objective: to dominate! My objective: to help you dominate!"

Similar presentations


Ads by Google