This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: MATLAB Reference Section: diagim} — returns the diagonal elements of are square matrix In termini — returns the value of e" factorial.th — returns the value of nt {accurate fer n s 21} sineim} — returns the lndices of the nonzero elements of the arraym
lengthie} — returns the largest dimension of the array a magic in: — creates an n x n 'magio square' array meta} — returns the value and index of the largest element in the array 3
manta} e returns the value and index of the smallest element in the array a
media, 1:}  returns only the remainder when a is divided by h ones (rows, eels} — creates a ratre )t eels arrayr in which every element is 1
sinttheta} — returns the sine of the angle theta {in radians} size tat — returns the dimensions of the array 3 semis} —~ returns the sum of all the elements in the array as zerestrews, eels} — creates a row: Jt eels array in which every element is e
a,  — used to perform element—oy—element logical operations on pairs of multielement vectors and arrays, as well as on pairs of scalar logical values
as. i  — used to perform logical operations on pairs of scalar logical values. and enables efficient, ‘short—circuif evaluation {but cannot be used on pairs of multielement vectors and arrays} CS 13?1 — Computing for Engineers Test 2 Version 1 Nov 2"”, 21305
1. Multiple Choice {20 pts) 1. 1Iliihich of the following is most commonly used in a recursive function? a. for
b. white C'ﬁ‘WeTs'r—e'ifm 3 . switchlcase 2. The amplitude versus time graph of an audio clip is a sinusoidal wave. the want to plot the
frequency versus the power. What is the first step to do this? a. Ffotate the plot by 91] degrees. b. Plot the square of the amplitudes.
CE) Perform an fft {Fast FourierTransform] on the amplitude versus time data. d. Perform an ifft {inverse Fast Fourier Transform] on the amplitude versus tlme data.
Ce; Perform an fit on the reciprocal of the square of the amplitude versus time data. 3. Which of the following is noftrue about the fat function:
E Goes between a time domain signal to a power spectral density.
at is a builtin Mattab function that performs a Fast Fourier Transform.
1.flrill change the number of data points for a sound and condense it at two points.
. Can be reversed using ifft to give the exact same data.
4. Which of the following isfare true about dimread [can pick more than one}
The input file has to be a text file. b. Uses a delimeter to differentiate behveen one number and another.
\s\ Can read in any type of data (numbers. strings. etc.) Ftetums an array of data BONUS {2 pts}: Why do British man not button the last button of their cardigans? ECDEFGHIJ Page 3 of El es 131  Computing for Engineers TestZVersion1 Nov 2nd, zoos 2. Plotting (20 pts) You are playing around with 3D plotting and want to compare two functions and using rnssh versus
surito plot. You decide to put the four graphs together in one subplot, as shown below: 2 f1lx,yi = 3x + 4y + 0.5*xy  x + y: 2 f2 = x + 3;? + sinixy}
1. it the range of both functions is between 1DEt and 10D. writs out all the code to generate .1 the valuesforfrlxgiandfelxwi. u .
\{a‘ﬁ \/ U Lilli... aw] : mahﬂﬁd is”; r/ I
101: 3“ W t ‘li‘W‘l + 'Jls.asa.>tYV<a.ne + 1+an «F1 3 xx. *2. r W4": 3r 9m {axﬁ‘l‘s’i
2. Writs all the oode used to plot the graph that has an arrow pointing at it [including subplot. labels. and title}. _ I L 1
I: liggpqu, [11:01 gout?r too} !"—}hti€('l:wrlm "LJ
1’"! . {label [‘w') Ck?" il. Fwd)
subsist (if? i'ﬂl/ : 715st”)  ] s22};st l w. m sinMaw) W—— 3. Why,r is rneshgrid used before defining values for f1 and is?
was and. Wastes a Mli'or'rt‘ﬁ all has; rams outs of. “PM. icliwsasuna' stdmu; all sat wows an that "“M it it“ ’3 WM ‘3'” H” ﬁlm” i. B C D E F G H I RheaEl. sash D": "HLL Pasta Page 4 of B CS 1371  Computing for Engineers Test 2 Version 1 Nov 2””, zoos
3. Images (20 pts)
Given the code below:
so A = imeadi impeacipa’ it
Answer the following questions. 1. Create a new image B that is the same as A. only upsidedown.
13;: tet[Eth11'i't}:3 L) f. _/ 2. Give the command to display:r B in a ligure. ﬂow it. E”:
d 3. create a new image, C, which is the same as A, except the green values are scaled so that the
maximum green value is 15G. 1‘45 C:¢~[:;:tl)* n' 4. What data type constitutes an FtGE matrix? What is the range ot this data type?
3 5+ {mar starii; vtv u. i M E: . ./'
Tom; 0525: I
L
5. Circle the error in the code below and explain the mistake: omit
"HMu.  E11" I. {.1 [Li 3 “3 .3
[It 0] = sizetsﬂiﬂﬁ _h_ I _ I I
HEWI; newc] = tfloorirﬂi. floortct’ﬂii; moi“ iialzrdk 13,. Laosmanning
I " ' i.:'.* 5.:1. GEL“ i': I..:‘ __l_
f0]: k = 1:3 T ILI'JJIH}. ~. I__ 3}
for 1 = hr  [Fme ﬂour“'3. Sittel ':."u.i'_'': [numil.
for j = 1:13 l”: F.I:I.':L'T:1.‘p_llrltltgl [Hzr if J”.
mYAVerage = meantmeaniAt2*i1:2*i, 2*j—l:2*j,k}n; “I “L M: = mYAVEragE; ".I K .I._‘_:I
and ‘LL Intuit“ hiltat. fl micn 4.“
o ,. t _
E91311 ' w»? W t"  JrLtME ear; I .{iuttt on F whim twrg with
which.1: a..'.«'..i:r.'va slut sooEPoHIJivtwv Page 5 of 3 CS 1331  Computing for Engineers Test 2 ldersion 1 Not.Ir 2"“, 20%
4. Metrioes and iteration (20 pts) Write a function called largestEuen which takes in an array and reiums a vector containing a 1 or i].
depending on whether or not the largest number in the column is divisible by two. The only,r builtin Matlab iunotion you can use for this problem is modﬂ. Ex: >1 largestEveni[1 2 3 4;2 3 4 5: 3 4 5 6]} ans = 1 o l D I
e} largestEVEHEEJJ E t ﬂ QKJt
ans = {I [J  ' n
{edition and, : Emotes. Editq {LIVill“ .i
if: CJ '' size [.anle ellis: Lottoﬂhfc); {if 1 '1: (,1. ~ “languid! 3 mm (I!  3 é‘of i “ liT' PI _ bani: l:l
II In HirerJ mini . ii Lmddﬂenvapnmd, 44‘] ' are = 13 end ﬁr} and BGDEFGHIJ Page 6 of B CS 13?1 — Computing for Engineers Test 2 Version 1 Nov 2’”, EDGE 5. Flecursion {20 pts} Write a recursive function called "power" which takes in two numbers and
returns the first to the power of the second. Make sure vour function
incorporates all three aspects of a recursive function. HiNTS: i. Fiecaii that raising any number to the power of zero is t
2. Your inputs wiii oniy be positive numbers 3. The oniv mathematicai operator you can use is iiit"! Ex:
is powert5.0}
one = >> power{2.3i
ans = ::: power [5 .2}
3.113 =
25 {motion on; : {musvia . r.)
1i?  :1 0
arts. 3 it] Page "i of E! ...
View
Full
Document
This note was uploaded on 11/08/2010 for the course CS 1371 taught by Professor Stallworth during the Spring '08 term at Georgia Tech.
 Spring '08
 Stallworth

Click to edit the document details