MATLAB homework 3 1.[10 pts] RevisitingMATLABmatrices andbuilt-infunctions.a)
MATLAB homework 3 1.[10 pts] RevisitingMATLABmatrices andbuilt-infunctions.a)
FactorthefollowingpolynomialsusingMATLAB:i. �! + 18� + 81ii. �! + 11� + 24iii. �! − 10� + 9iv. �! − 4�! + 4� − 16v. 2�! − 16� − 40b) Multiply the following vectors using “dot” multiplication. What does this type ofoperationdoincontrasttotraditionalmatrixmultiplication?i. [5,6,9]’with[10,10,10]’ii. [1,1,1]’with[2,5,1]’iii. � = 1 39 10 with� = 4 510 22. [30pts] PlottinginMATLAB.a) Considerthefollowingfunction:� = � � = sin � + �! + 6!Createvectorsfrom-10to10withthefollowingstep-sizes:i. 5ii. 1iii. 0.1iv. 0.001v. 0.00001plottheresultsonthesamegraph.Addaxislabels,titleandlegend.b) Createmultiplefigures,plottingalldatafrompart(a).Createnewtitles,asnecessary.Changethelinestylestothefollowing:i. red,black,green,cyan,magenta – gridonii. blackdiamonds,redcircles,bluex’s,dashedmagenta,dottedgreen – gridoffiii. blackasterisks,redsquares,dottedred,bluedashes,magentasquares– gridonMAE215:IntroductiontoProgramminginMATLABSummerB2016HomeworkAssignment#3Due:Tuesday,July19th by11.59pmc) Considerthefollowingfunctions:�! = 6sin �! + cos 2�!�! = 12sin 2�! + cos 4�!definex1 from0to2� withthefollowingnumberofelements:i. 10elementsii. 100elementsiii. 1000elementsiv. 10000elementsforeach(i)– (iv)above,evaluatey1 andy2.Createasinglefigurewindow showingtheprogressionofresolutionaselementsareaddedtox1.Eachplotshouldhavealegend,appropriatetitleandaxislabelandincludetheresultsfrombothy1 andy2.(hint:usesubplots).d) Considerthefollowing twofunctions:�! � = 3�! + 3� + 87�! � = �2 + 3 + 64�evaluatethesefunctionsfromx=0to100inastepsizethatgivesacceptableresolution(useyourjudgment!).Plottheresultsonthesamefigure.Whatisoneproblemwiththefiguregenerated?FindanotherMATLABfunctionthatwillfixthisplottingissueandregenerateyourplot.Addappropriateaxislabels,legends,titles,etc.e) Considerthedatasetgivenbythexandyvectorsbelow:y=[3,15,26,35,41,52,60,77,84,90,95,100] x=[5,10,15,20,25,30,35,40, 45,50,55, 60]Plotthisdatausingasemi-logscale,creatingaplotthathasanaturallogararithmicy-axis.(hint:semilogy()).3. [40 pts]WorkingwithMATLABfunctionfiles.a) Write a function file, that accepts values of x asinputs and outputs the value of ywhentheinputispassedthroughthefollowingfunction:� = � !”!!!.!” + 4� + 0.2�!evaluatethefunctionatarangeofxvaluesfrom0to1with143elements.b) Consider the functions below, both of which are dependent on a single input, x.Createafunctionfilethatwillreturnthevalueofbothcalculationswhenprovidedavalue(orseriesofvalues)ofx.Evaluateyourfunctionsforxvaluesof1,2,3and4aswellasthevectorfrom0to10with1000elements.Plotyourresults,addingfigurelabeling, legends, etc. as necessary. You should present two plots, each with twolines.�! = � + 5�! = �!! + sin (�)MAE215:IntroductiontoProgramminginMATLABSummerB2016HomeworkAssignment#3Due:Tuesday,July19th by11.59pmc) Modifyyourfunctionfrom3(b)sothat,afterevaluatingthevalueofy1 foragivenvalueofx,anintermediatecalculationisperformedwhichdividesxby10beforeitisusedinevaluatingy2.Evaluateyourfunctionatthesamepointsas3(b)andcomparetheresults.d) Createafunctionfiletoevaluatethevalueofsin � accurateto9Taylor seriesterms.Recall,theTaylorseriesforsin � isgivenby:sin � ≈ � − �!3!+�!5!− �!7!+�!9!− �!!11!+�!”13!− �!”15!+�!”17!*NOTE:Therearemultiplewaystodothisproblem.Thinkitthroughbefore youcode!Evaluateyourfunctionatvariouspointsonthedomain[0, 2�]. (atleast3)e) Createafunctionfiletoevaluate themultivariablefunctionf(x,y,z)below.� �, �, � = �!��! + �! + �!�evaluatethefunctionatthefollowingpoints:(1,1,1),(1,0,1),(e3,1,5).f) Consideranobject,whosepositionalongthex-axisisgivenby:� = 12 ��!create afunctionthathastimeasaninputandreturnstheposition(alongx) oftheobject,thex-axisvelocityattime“t”andtheaccelerationoftheobject.(hint:thinkabouthowmanyoutputsthefunctionmusthaveandhowtorelatethevelocityandaccelerationtothegivenfunction).Plottheabovequantitiesfromt=0to10with100elements.Youshouldusesubplotwhere,fromtoptobottomtheplotsshouldbeintheorder:position,velocity,acceleration.Allplotsshouldbelabeledappropriately.g) Createanonymousfunctionsinyourscriptfiletodefineandevaluatethefollowingfunctions:i. � � = �! + 4� + 6forx=1,5,10ii. � �, � = �� + �!� − �!(� − 1) for(1,4),(-1,-4),(4,1)iii. � �, � = sin � + cos 2�for(0,0),( !! , !! )iv. � �, � = �!” + ln 4� − log!” 5��for(1,1),(6,4),(2,10)