Matlab Review/Tutorial: Chemical Reaction Engineering CBE 40445
Matlab Review/Tutorial: Chemical Reaction Engineering CBE 40445
Matlab Review/Tutorial: Chemical Reaction Engineering CBE 40445
Matlab Basics
access Matlab from both UNIX and PCs in ND clusters Can buy student version from OIT Applications Requested & Approved for Fall 2008
MATLAB
7.6
Can
Matlab Basics
command window Command line (>>) Can execute commands directly from command line >> a = [ 1 2 ; 2 1 ] 1 2 a 2 1
Perform
Can
Matlab Basics
Trigonometric functions
sin(x),
you need more than one line of code When program will be used again When a permanent record is desired When occasional upgrading will be required When substantial debugging will be required When you want or need to transfer to another person (a.k.a to your teacher!)
Structured Programming
Refers to the organization and format of a program Organization: how do we complete a task?
Input:
read values from a source Process: calculate/manipulate numbers Decide: choose a path based on a requirement Output: present result(s)
Date
originated Date revised Description of input/output: number, meaning, type, etc. Descriptive comments throughout!
Description Example
%******************************************************* % Purpose: MATLAB Tutorial % Name: Dr. Jes Anderson % Date originated: Aug. 18, 2008 % Date revised: Aug. 29, 2008 % Description: Remind students of basic matlab operations % and programming skills % %*******************************************************
Example 1 Program basics Example 2 Vector and matrices review Example 3 Creating graphs Example 4 Functions Example 5 Systems of Equations Example 6 Integrals and ODEs
Find
Example 3: Plotting
in both 2D and 3D Apply axis labels, titles, legends Change output colors/shapes/etc. Make new figures or subplots within figures **Be able to communicate your data to others!!!
Some more plot customization commands to type before plot() or plot3() figure(n) opens a new figure window subplot(m,n,p) divides a single figure window into an m x n grid and puts your next command in the pth spot grid on/off displays a grid hold on/off superimposes plots