Tutorial-1 Intro Videos Build HW File Engr/Math/Physics 25

advertisement
Engr/Math/Physics 25
Tutorial-1
Intro Videos
Build HW File
Bruce Mayer, PE
Licensed Electrical & Mechanical Engineer
BMayer@ChabotCollege.edu
Engineering/Math/Physics 25: Computational Methods
1
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_MATLAB_OverView-1.ppt
First ENGR25 Tutorial
 MATLAB Video Tutorials
• http://www.mathworks.com/academia/stud
ent_center/tutorials/launchpad.html
– http://www.mathworks.com/videos/gettingstarted-with-matlab-68985.html (6 min) 
– http://www.mathworks.com/videos/writing-amatlab-program-69023.html (6 min) 
– http://www.mathworks.com/videos/matlab/using
-basic-plotting-functions.html (6 min)
– http://www.mathworks.com/videos/simulink/getti
ng-started-with-simulink.html (3.5 min min)
Engineering/Math/Physics 25: Computational Methods
2
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_MATLAB_OverView-1.ppt
First ENGR25 Tutorial
 MATLAB Video Tutorials
• http://www.mathworks.com/academia/stud
ent_center/tutorials/launchpad.html
– http://www.mathworks.com/videos/matlab/creati
ng-a-basic-plot-interactively.html (6 min)
 See Also
• Day1_HW_Build_Tutorial_1201.m
Engineering/Math/Physics 25: Computational Methods
3
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_MATLAB_OverView-1.ppt
HW File MSWord Starting Point
Engineering/Math/Physics 25: Computational Methods
4
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_MATLAB_OverView-1.ppt
HW00 P01  Trapezoid Area
 Consider an
ARBITRARY
Trapezoid
a
 The ALGEBRAIC
formula for the Area, A
h
b
 a & b are BASE
Lengths
 h is the Height
Engineering/Math/Physics 25: Computational Methods
5
 The Area of this form
is the AVERAGE OF
THE BASE-LENGTHS
times the HEIGHT

a  b
1
A
h  a  b h
2

a  b h
A
2
2
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_MATLAB_OverView-1.ppt
HW00 P01  Trapezoid Area
 Ask user to enter a, b, h
 Calc & Display Trapezoid area
a

a  b
A  Base Avg Hgt  
h
h
2
b
Engineering/Math/Physics 25: Computational Methods
6
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_MATLAB_OverView-1.ppt
HW00 P03  Quadratic Eqn
 Ask user to enter a, b, c for Quadratic
Eqn shown below
 Display Solution
0  ax  bx  c
2
Engineering/Math/Physics 25: Computational Methods
7
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_MATLAB_OverView-1.ppt
HW00 P07  CoSine City
 Find Difference in MATLAB CoSine
Calcs
2
v1  cos e 
v2  cos e 
2

v3  cos  e 
Engineering/Math/Physics 25: Computational Methods
8
2

Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_MATLAB_OverView-1.ppt
HW00 P11  Base 𝒆 Exposed
 Plot This Function
T  6 Clnt t0   7e
0.2
t
min
• Where
– T  Temperature (°C)
– t  time (minutes)
– t0  = 3.3 minutes
• For 1  t  9
Engineering/Math/Physics 25: Computational Methods
9
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_MATLAB_OverView-1.ppt
HW00 P15  SimuLink City
 Solve the ODE below using the Icon
Based Programming Environment,
SimuLink
12
 sec5 2  d 2 y  sec3 2  dy
sec
 3
 t
5

 7
2
m
 m  dt   m  dt
dy
m
3
dt t 0
sec
y 0  11 m
Engineering/Math/Physics 25: Computational Methods
10
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_MATLAB_OverView-1.ppt
HW00 P23  MuPAD Manipulation
 For
𝑑𝑦
𝑑𝑥
 Find
Using
MuPAD
𝑓 𝑥 𝑑𝑥
Plot 𝑦 = 𝑓 𝑥 vs 𝑥 for 0 ≤ 𝑥 ≤ 2
Engineering/Math/Physics 25: Computational Methods
11
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_MATLAB_OverView-1.ppt
HW00 P31  Excel Exposure
 Compare Industrial
Machine Tool
Products from
Gladiator
Engineered
Systems (GES)
and the
Competition Thru
the use of an Excel
RADAR Chart
20
18
16
14
12
10
8
EaseOfUse
Engineering/Math/Physics 25: Computational Methods
12
Competition
Analysis
Space
Cap Cost
6
4
2
GES
Brand X
0
Op Cost
Reliabilty
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_MATLAB_OverView-1.ppt
Windows ClipBoard Copy

MATLAB provides a Very Nice Utility in which
a Plot is sent to the MSWindows ClipBoard
for Subsequent Pasting into Other
Applications

To Save to the ClipBoard
1. Select Copy Options from the Edit menu. The
Copying Options page of the Preferences
dialog box appears.
2. Complete the fields on the Copying Options
page and click OK.
3. Select Copy Figure from the Edit menu.
Engineering/Math/Physics 25: Computational Methods
13
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_MATLAB_OverView-1.ppt
Copy to Clipboard  Step-1
1. In Figure 1
Window
Click Edit
→
Copy
Options...
Engineering/Math/Physics 25: Computational Methods
14
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_MATLAB_OverView-1.ppt
Copy to Clipboard  Steps 2&3
2. In the
Preferences
Dialog Box
check the
CopyOptions
Boxes as
you see Fit
3. Close the
Dialog Box
Engineering/Math/Physics 25: Computational Methods
15
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_MATLAB_OverView-1.ppt
Copy to Clipboard – Steps 4&5
4. In the Figure
Window use
File → Copy
Figure to send
the plot to the
clipboard
5. Paste the plot
image into
PowerPoint,
Word, etc.
Engineering/Math/Physics 25: Computational Methods
16
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_MATLAB_OverView-1.ppt
The Copy Figure export
600
500
y = f(x)
400
300
200
100
0
-100
-2
-1
0
Engineering/Math/Physics 25: Computational Methods
17
1
2
x
3
4
5
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_MATLAB_OverView-1.ppt
Copy SimuLink Model
 A SimuLink Model
Engineering/Math/Physics 25: Computational Methods
18
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_MATLAB_OverView-1.ppt
The Copied Model
Ambient
Temp, Ta
1028
T-Stat
qm
0.0389
0.5
1/RC
R
1
s
simout
Integrator
IC = 70°F
Plot Ta & T(t)
1/100
Scale Output
Engineering/Math/Physics 25: Computational Methods
19
1
s
DeBug
Scope
Total
Energy
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_MATLAB_OverView-1.ppt
Copy MuPAD Symbolic Math
 A MuPAD WorkBook
Engineering/Math/Physics 25: Computational Methods
20
 Select Content
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_MATLAB_OverView-1.ppt
Copy MuPAD Symbolic Math
 In MSWord use:
• PASTE SPECIAL
• FORMATED TEXT
(RTF)
Engineering/Math/Physics 25: Computational Methods
21
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_MATLAB_OverView-1.ppt
Copied MuPAD WorkBook
Engineering/Math/Physics 25: Computational Methods
22
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_MATLAB_OverView-1.ppt
3x3 from ENGR43
 For The DC Linear Circuits We Will
need to Solve Systems Of Algebraic
Equations
R2
2.2 kΩ
I2
R3 1.2 kΩ
1.5 kΩ
I3 Rx
R1
2.7 kΩ
7 mA
RL
13V
I1
IL
1.8 kΩ
Engineering/Math/Physics 25: Computational Methods
23
12V1  9V2  4V3  8
 4V1  16V2  V3  0
 2V1  4V2  6V3  20
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_MATLAB_OverView-1.ppt
First ENGR25 Tutorial
– Additional Videos Useful in the future
 http://www.mathworks.com/videos/matlab/importingdata-from-files.html (HW5, 7min)
 http://www.mathworks.com/products/simulink/demos.
html?BB=1 (SimuLink)
 http://www.mathworks.com/videos/simulink/getting-started-withsimulink.html (4 min)
 http://www.mathworks.com/videos/simulink/visualizingsimulation-results.html (4 min)
 HW Presentation  Save MATLAB
work to MSWord file
• Trapezoid area, 3x3 Eqn System, cosh
calculation, plot y = ln(t+.02)·sin(1.3t)
Engineering/Math/Physics 25: Computational Methods
24
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_MATLAB_OverView-1.ppt
Additional Useful Videos
http://www.mathworks.com/products/matlab/demos.html
Engineering/Math/Physics 25: Computational Methods
25
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_MATLAB_OverView-1.ppt
Day1 demo Script
Engineering/Math/Physics 25: Computational Methods
26
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_MATLAB_OverView-1.ppt
DeskTop Recovery
to UnScramble the DeskTop
Engineering/Math/Physics 25: Computational Methods
27
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_MATLAB_OverView-1.ppt
All Done for Today
Please Try
Using
MATLAB
 Let’s do MQ-00b
Engineering/Math/Physics 25: Computational Methods
28
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_MATLAB_OverView-1.ppt
A Trapezoid
t
h
b
 A = [Hgt] x [Avg-Width]
Engineering/Math/Physics 25: Computational Methods
29
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_MATLAB_OverView-1.ppt
Cosh City
>> fplot('cosh', [-2 2])
>> grid
4
3.5
3
2.5
2
1.5
1
-2
-1.5
-1
-0.5
Engineering/Math/Physics 25: Computational Methods
30
0
0.5
1
1.5
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_MATLAB_OverView-1.ppt
2
3x3 from ENGR43
 For The DC Linear Circuits We Will
need to Solve Systems Of Algebraic
Equations
R2
2.2 kΩ
I2
R3 1.2 kΩ
1.5 kΩ
I3 Rx
R1
2.7 kΩ
7 mA
RL
13V
I1
IL
1.8 kΩ
Engineering/Math/Physics 25: Computational Methods
31
12V1  9V2  4V3  8
 4V1  16V2  V3  0
 2V1  4V2  6V3  20
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_MATLAB_OverView-1.ppt
Example Problem 1-21
 Plot This Function
T  6 ln t  7e
0.2t
• Where
– T  Temperature (°C)
– t  time (minutes)
• For: 1  t  3
Engineering/Math/Physics 25: Computational Methods
32
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_MATLAB_OverView-1.ppt
Prob 1-21
t = [1:.01:3];
T = 6*log(t) - 7*exp(0.2*t);
plot(t,T, 'LineWidth', 3)
xlabel('t (Sec)')
ylabel('T (deg C)')
title('Temp vs time')
grid
Temp vs time
-6
-6.5
-7
T (deg C)
>>
>>
>>
>>
>>
>>
>>
-7.5
-8
-8.5
-9
Engineering/Math/Physics 25: Computational Methods
33
1
1.2
1.4
1.6
1.8
2
t (Sec)
2.2
2.4
2.6
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_MATLAB_OverView-1.ppt
2.8
3
Engr/Math/Physics 25
Appendix
Bruce Mayer, PE
Licensed Electrical & Mechanical Engineer
BMayer@ChabotCollege.edu
Engineering/Math/Physics 25: Computational Methods
34
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_MATLAB_OverView-1.ppt
Example Demo Session
>> %Use MATLAB As Calculator
>> (7+11)*2.5
>> 17*19
ans =
ans =
45
323
>> L = 14.4
>> 77/19 -4.3
L =
ans =
14.4000
-0.2474
>> W = 13.3
>> 64^(1/3) + 32^0.2
ans =
W =
13.3000
6
>> Area = L*W
Area =
Engineering/Math/Physics 25: Computational Methods
35
191.5200
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_MATLAB_OverView-1.ppt
Prob 1-21 Command Script
 From the Command Window
>> t = [1:0.02:3];
>> T = 6*log(t) - 7*exp(0.2*t);
>> plot(t,T), xlabel('time
(min)'),ylabel('Temperature (°C)'),
title('Problem 1-21'), grid
Engineering/Math/Physics 25: Computational Methods
36
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_MATLAB_OverView-1.ppt
Prob 1-22 Plot
Engineering/Math/Physics 25: Computational Methods
37
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_MATLAB_OverView-1.ppt
Problem 1-22
-6
Temperature (°C)
-6.5
-7
-7.5
-8
-8.5
-9
1
1.2
1.4
1.6
1.8
2
2.2
time (min)
Engineering/Math/Physics 25: Computational Methods
38
2.4
2.6
2.8
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_MATLAB_OverView-1.ppt
3
The Copied
MuPAD WorkBook
Engineering/Math/Physics 25: Computational Methods
39
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_MATLAB_OverView-1.ppt
System, Directory, File Cmnds
Command
Description
pwd Displays the current directory
Changes the current directory to
dirname
Removes the directory dirname from
rmpath dirname
the search path.
cd dirname
Lists the MATLAB-specific files found in
the current working directory. Most data
what
files and other non-MATLAB files are
not listed. Use dir to get a list of all files
what dirname
Lists the MATLAB-specific
files in directory dirname
Engineering/Math/Physics 25: Computational Methods
40
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_MATLAB_OverView-1.ppt
Download