Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Save to My Library
Look up keyword
Like this
1Activity
0 of .
Results for:
No results containing your search query
P. 1
Previous ECE Exam-1

Previous ECE Exam-1

Ratings: (0)|Views: 41 |Likes:
Published by Secret Squirrel

More info:

Published by: Secret Squirrel on May 14, 2009
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

05/11/2014

pdf

text

original

 
an effor, wite"errof'.
,,'1t)
A. cat(1,A,c)B. A./C
D=
qo
0tl
'l
G-a9+Lb
'1a
=-<Y
11t-4
a,Jd'ial
t0-3D8
/
tr-
,lLarab
5D0t1ltb
-_)-3voJ
=l.DooD0,2
C. A*D
llt3
E.find(A>c)
Page2of 8
lr;itti,C.r.\J!.r5
1.(10 pts)Assume irst hat the followingnstructions avealreadybeenenterednto MATLAts:A=12_34 0l;
B=[4;-j-2;4;-A2);
c=t21?-0111,3
D-[35; B10; 5'7;1113];
rVowssume hat he followingnstructionsre entercdntoMATLABn theordergiven.Undereachone,wite the output hatMATLABwillproduce.Yaucanomit he"ans=".lf the entry wil! result n
F. linspace(3,12,s})
G.po1lrval(C,2)
:75
H. D(2--3,L:2)
l2
t/v
?tD57
t ,-"
*r41 ,,"nh
r|trty,
I"[x,ki=rT.sun(D)max(B)
Y=1
(=l
L/
2-7
3S
o
 
2.(15ptstotal)Supposehat matrixI is previouslydefined.fhe follo$,ingcornmandhasalreadybee.n ntered nMATLAB:[mnl:size(.,l);trllhe spaccsprouided,rvrite the MATLABcommaldsto do thefollovring.Use onlyMATLAE's implier.{Xoops(arrayopcrations&functions|-noexpliclt ioopsarepermitted.Considereachcaseseparately.a. Deletehc4'h column of A,r/'
b.Assuminghat he first rowof A containsfle"x-" coordinatesndhesccondowof A <;ontains-bcy-coordinates"f a curve,generaten"x-y"plot-useasr.noothedine.Give heplotthe nameExam 2P\ot,labelhe horizontalxis towI Aand heverticalaxis Rorv2 A.
A(:,'l)=11
,3=gft45tFLn\
L=6,^r)(A+r\./
d. Countthenumber of entries nA tiratarestrictlybiggerhan3,
,(,^n[Surn(Ax,)
v_.\/
e.Createnewmatrix D which sthe same sAexcepthat everyelementn Atliatisgreaterhan 10s replacedbv 5andeveryelementhat s lesshanor equal o10 s replaced y-5"
'-):..)
D=F
b(frto)=5
b(AK=D=-s
p\otoCt,i\,(r,,,),,r),,+le,{xamfbl),laLl('furunhlabtl[,fo,"n)::t
c. Create a new matrixC by squaring eachelementof A and then chvidingtVth._p_fr_gBgg$.llg.*eJcmenlinhesum of A andBwhereB is thesamesizeasA birthasallelementsequalo l.(YouwiJl haveogenerateB, it rsnotalreadYdec-^'rr\
t
Page3of 8
 
3.(20ptsotal)Useonly MATLAB'simpliecloopsarrayoperationsfunctionsFnoexplicitoopsarepermittedneitherpartsbelow!
a.(l0pts).Writeai:nctionnamedAavgthat hasonenputparamcteramcdAwhich santmxn matrix. Theirnctionshould eturnhrceterns-The irst items a rov,vectornarneda.Eachelemcntof ca should lethe averagef the clcmentsn thecorrcspondingcglumn9r{,after"dropping" he smallest alue,That s,ca[] will bc theaveragef thc rernainingalues ncolurnn1ofA afler droppinghe smallest aluencolumn 1. ca[2]willbe he averagef thc remainingaluesncolunm2ofAafler droppinghesmallest alue n columl 2,etc.The matrix A mu.stotbechzmgedy this calculation!Thc secondtem isacolumneclornarned a-Eachelement f rashoulde he averagefthcelementsntlrecorrespondingowofA'afler"dropping" le largestalue.That s, ra[l]rvill tre heaverage f t}e remainingaluesnrow Iof A aflerdropping the largestvaluenrow 1. ra[2]will be the averageof theremainingvaluesn row 2ofA:rJlerdroppinghe argest alue n row 2,etc.ThernatrixA mustnot be changedythis calculation!Thehird itemrehrrnedsa scalarnamedwhichsthe average f allof theelementsf thearray
Iun+iot\lcrIyA/yj
.'t-
r)A--l-nrud'arra'1
--f'^;q)
rft
=l?,7)t
=F,4,t
F,nl=ury,Cft))
Ca
(4,
= SurnCn)-Y,'ntn)Q-t)',
o
L)c,L,l=Aav!(
x\h
)
A1)K
<\^
=Surn[n)'mlntn\t@-\)
b.(l0pts)Writea scriptwhich willaccomplishhe ollowing tasksn order:1) oad thecommadelimiteddataromthe frleiirrayl)ata.Lxtnto the arrayA2)invokehe incfion Aavgbypassinghepararnetertoitandplacinghe returnvalueslthe variablesC, ld andxinthatorder3)appendCto Aso hatt istheastrow ofA4) appendto R sohatit is in the ast rowofR5)appendRtoAso thatit isthelastcolumnof A
Page4 of8

You're Reading a Free Preview

Download
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->