ECOR 2606 Lecture Notes - Lecture 14: Matlab, Length Overall
ECOR 2606 D/E - Lecture 4 – 17/01/2018
ADMIN - Register culearn for correct lab section
- PMC students – send LOA
SNAP QUIZ
1. Make the minimum number of changes necessary to make the following MATLAB code vector
friendly with respect to x
y = 2/(x^2 + 4*x -6)
a) y = 2./(x^2 + 4*x -6); (need a . between x^2) – WRONG
b) y = 2.(x.^2 + 4*x – 6) CORRECT ANSWER
c) y = 2./(x^2 + 4.*x – 6) do’t eed a dot etee .*, is salar ties etor WRONG
d) y = 2./(x.^2 + 4.*x.-6) do’t eed dot eteen x.-6) – WRONG
2. Ho a redudat . Are there i total i the folloig to epressios:
F1 = @(x) x.^2 – 5.*x + exp(x./2)
F2 = @(x) 20*cos(6*x).-2*x
a) 0
b) 1
c) 2
d) 3 (CORRECT)
e) 4
f) More than 4
Note: Scalar times vector = NO DOT, dot only for element by element operations
- Should be no dot at 5.*x and at x./2 and at (6*x).-2
Lecture 4: for, while, functions, void functions, direction of matrices
Plot – plots data
fplot – plots functions
- Code on the right plots pressure ratio of mach numbers from 0
to 7
-when file function is used as input to another function, name of
function is preceded with @
-PR function not vector friendly, will not work if it is given vector
of input values
find more resources at oneclass.com
find more resources at oneclass.com
Document Summary
Ecor 2606 d/e - lecture 4 17/01/2018. Admin - register culearn for correct lab section. *x 6: y = 2. /(x. ^2 + 4. *x. -6) (need a . between x^2) wrong. Correct answer (cid:894)do(cid:374)"t (cid:374)eed a dot (cid:271)et(cid:449)ee(cid:374) (cid:1008). *(cid:454), is s(cid:272)alar ti(cid:373)es (cid:448)e(cid:272)tor(cid:895) wrong (cid:894)do(cid:374)"t (cid:374)eed dot (cid:271)et(cid:449)een x. -6) wrong. Ho(cid:449) (cid:373)a(cid:374)(cid:455) redu(cid:374)da(cid:374)t (cid:862). (cid:863) are there i(cid:374) total i(cid:374) the follo(cid:449)i(cid:374)g t(cid:449)o e(cid:454)pressio(cid:374)s: F2 = @(x) 20*cos(6*x). -2*x: 0, 1, 2, 3, 4, more than 4 (correct) Note: scalar times vector = no dot, dot only for element by element operations. Lecture 4: for, while, functions, void functions, direction of matrices. Plot plots data fplot plots functions. Code on the right plots pressure ratio of mach numbers from 0 to 7. When file function is used as input to another function, name of function is preceded with @ Pr function not vector friendly, will not work if it is given vector of input values.