class_notes14

# class_notes14 - – contents – index – search – demos...

This preview shows pages 1–10. Sign up to view the full content.

Engineering 3 – Class 14 Today: •MatLabintro! • environment walk-around • comparison with C

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
onward to MatLab… • Compiled vs. Interpreted languages • Comparison -find sin(x) for in steps of 0.1 -plot? π 2 0 x
Desktop Environment • command window • workspace • current directory • command history • toolbar Matlab

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
A certain cylindrical tank is 15 m tall and has a radius of 8 m. Design another cylindrical tank with a volume 20 percent greater but having the same height. Example h V r π = h r V 2 =
Arrays • arrays are one the of main strengths of MatLab • to create an array, simply: >> x = [0, 1, 3, 6]; • if values are regularly spaced: >> x = [0:0.1:10]; • addition, subtraction, length() • can be used with any built in function

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Plotting • straightforward plot generation is another strength of MatLab • to create a plot, >> plot(x,y); where x values are on horizontal axis, and y values on vertical • if values are regularly spaced: >> x = [0:0.1:10]; • addition, subtraction, length()
HELP! • Matlab has excellent built-in documentation.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: – contents – index – search – demos • From the command prompt: >>help function_name >>doc function_name Script Files • Matlab can be run interactively, or commands can be saved in a script file (also called an ‘ m file ’) • running an m-file is equivalent to typing commands, one at a time, at the Command window prompt • create in a couple of different ways: >>edit file_name.m – File/New or Toolbar button • for comments, use % Input and Output • to get input from user, use input() function: >> n = input(‘Enter value:’) • for output, use either disp() or fprintf() function >>disp(‘value is: ‘); >>disp(n); or >>fprintf(‘value is %d\n’, n); Note that single quotes are being used instead of double quotes Repetition and Decision Making • introduction, plot the function: for -5<=x<=30 ⎪ ⎩ ⎪ ⎨ ⎧ + + = 10 10 10 10 4 15 x x y 9 9 ≤ ≤ ≤ ≥ x x x...
View Full Document

{[ snackBarMessage ]}

### Page1 / 10

class_notes14 - – contents – index – search – demos...

This preview shows document pages 1 - 10. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online