EGR 103/Fall 2013/Lab 3
(Redirected from EGR 103/Fall 2013Lab 3)
Jump to navigation
Jump to search
Concepts discussed during explanation of each problem:
- First problem: Van Der Waals Equation
- Use of strings in MATLAB
- Numerical values stored for letters
- Issue with strings of differing lengths
- strcmp command
- Use of switch...case statement instead of if tree with strcmp
- otherwise case
- multiple triggers with {'trigger1', 'trigger2', ... }
- Only good for exact matches
- Plotting using different point styles
- Use of strings in MATLAB
- Second problem: Beam Displacement
- if statements and logic
- implied all() with logic
- MATLAB:Logical Masks
- Be careful about (logic) .* (function) versus logic .* function
- 2<1*3 yields "true"
- Never use a<X<b; use a<X & X<b instead
- a<X\(<\)b yields all 1's if b>1, regardless of a or X values
- Be careful about (logic) .* (function) versus logic .* function
- find command
- Finding non-zeroes
- find(X)
- find(A>0)
- Using indices to determine values
- X(find(X)), A(find(A>0)), t(find(y==min(y)))
- Finding non-zeroes
- Using more points for better answer
- MATLAB tolerance and dangers of ==
- min(y)==-1 fails
- format long e shows why
- use abs(min(y)-(-1)) < tol instead for some value of tol
- Speed of displaying versus creating matrices
- Problems using huge number of points for plot
- if statements and logic
- Third problem: Pipe
- Notion that functions can do more than just calculate matrices
- Fourth problem: Leap year
- Notion of validating inputs
- Using nargin to check input count along with if tree
- error command
- Use of testing function to create diary
- Fifth problem: Rocket
- Use of anonymous function with logical mask