Lab report exercises in mathlab, Lab Reports of Mathematics

answered sample exercises in matlab laboratory reort

Typology: Lab Reports

2019/2020

Uploaded on 08/23/2020

rommel-esteves
rommel-esteves 🇵🇭

1 document

1 / 5

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
pf3
pf4
pf5

Partial preview of the text

Download Lab report exercises in mathlab and more Lab Reports Mathematics in PDF only on Docsity!

Ecitor File Edit View Debug Run Help j@- ea ja OHeiteec’ @ Command window >> HeronsFormula m feron's Forma Side @ of the triangle:5 Side b of the triangle: HeronsFormula.m EJ SineLaw.m (£9 CosineLaw.m EJ __VolumeOfTruncatedCone.m [ VolumeOfTruncatedPrism.m EJ 4 Wi side c of the triangle:10 Dffidisp (‘Heron's Formula’) a as 5.00, b as 7.00, and c as 10.00 2 a = input("Side a of the triangle:"): The azea of the triangle is 170. 41127. 3 b= imput('Side b of the triangle:'): >| 4 oc = input("Side c of the triangle: ")e Soh (at+bec) /2; 6 area = sqrt (h* (h-a)* (h-b) *(h*e)): TEjif (real (area)==0) 8 fprintf('a as %.2f, b as %.2f, and c as %.2f\n',a,b,e) 9 | fprint£('Not a txiangle') 10 | else 11 fprintf('a as %.2f, b as %.2f, and c as %.2f\n',a,b,e) 12 fprinti('The area of the triangle is %.5£.\n',area); 13 Lena Editor BX Command Window File Edit View Debug Run Help >> SineLaw 7 Sine Law OB SHS So? Fx OBlsieaos tot fs unknown? cay for angie for sess = = = = yp, side lengeh:15 HeronsFormula.m [J SineLaw.m EJ Cosinetaw.m [J VolumeOfTruncatedCone.m [EJ __VolumeOftruncatedPrism.m [J 4 Wi angie (in degree) :20 Ty disp(sine Taw) other given angle:35 2 (find = input('What is unknown? for angle for side:','s"): The triangle with 15,000 side length and 20.000 3 sidel = input('side length:'); eee ‘the unknown 25-185 sid= length and 35.000 4 Amput (‘angle (in degree) :'); 5 deg2rad(angl) ; é 7Eit (find == '2") 8 input (‘other given angle:")+ 8 deg2rad(ang2); 10 side2 sidel*sin(ang2) /sin(angl) ; 11 | elseit a2 | (find == '") 13 | side2 = input (‘other given side length: a4 | ang2 = asin(sin (angi) *side2.side1) ; 15 | else 16 disp('Invalid Input") 17 | return as ig rad2deg(angl) 20 rad2deg(ang2) ; 21 fprintf('The triangle with %.3f side length and %.3f\n degrees',sidel,angl): 22° fprintf(' has the unknown %.3f side length and %.3f\n degrees', side2,ang2) Ecitor File Edit View Debug Run Help ‘Command Window >> CosineLaw Mm Cesine Law What is unknown, or :Side First sid VolumeofTruncatedPrismm (=) 4 Wi second side:é A@-&h noe tzeeaoce HeronsFormuia.m [ SineLaw.m CosineLaw.m EJ VolumeOfTruncatedCone.m (&5 2° find input ('What is unknown, or :','s')? 3 E)function whatAngle = angleX(x,y,2,find) 4 5 switch (find) é whatAngle = acosd((y*2+z°2-x%2) / (2*y*z))z 3 whatAngle = acosd((x*2+z*2-y*2) /(2*x*z))y 12 whatAngle = acosd((x*2+y*2-z*2)/(2*x*y))s 13 fprintf£('Angle C is %5.2degrees.',whatAngle) Taf] omervice 15 disp('Invalid') Tell enaaxiten 17 Lena 18 E)function whatSide = sideX(x, y, deg) |] Angle between two sides:50 The third side length is 4.74units.>> ig whatSide SQIt (x*2+y"2-2*x* y*cosd (deg) ) + 20 fprintf('The third side length is %5.2funits.',whatSide) 21 Lena 22 Ejswiteh (find)| 23] case ‘ancie! 24 a = input ('Side a:')+ 25 b = input ('Side bs"); 26 e = input ('Side o:"): 27 Hind = dnput (‘Usimown angle “Ay os “BS oe “OS s',!a!)s 28 whatAngle = angleX (a,b,c, choose) ; 29 | case 'Sice! 30 a = input (/Fizss sace:'); 31 b= input('Second sidei')i 3. deg input (‘Anois beu tI sidesi'l: ’ Editor © Command window File Edit View Debug Run Help >> VolunegTruncatedcone D@-S&S\o Plex Rtieact mjclume og srucared cone = = = _. |) Radius of smaller base:5 ‘HeronsFormula.m [J SineLaw.m EJ __CosineLaw.m [J VolumeOfTruncatedCone.m EJ VolumeOfTruncatedPrism.m (=) 4 Wradius of larger bas: Tjdisp("Volune of cruncatea cone’) The volune of the truncated cone with dimention of + 2 oh = input ('Height:'); P5-00 units as the height 3 ox = input (‘Radius of smaller base:'); ee ee 3g a niga reuas, 4 R = input (‘Radius of larger base:'): is 2026.33 cu.units. 5iVv (pi/3)* (r*2+R*2+R*r) *h: > 6 fprinte(*The volume of the truncated cone with dimention of : 7 prince ($5.25 unis as che height \n',B) ® fprintf('s5.2f units as the smaller radius \n',r) § fprintf('35.2f units as the bigger radius \n',R) 10 fprintf('is $5.2f cu.units. \n',V) vine 7X. Command * ble kat View Lebug Run Help 2p olunedCTeuncetedciom H@-Sh3\6 (a etieaoe : een cf sae base eriangie: 24 Houstvnden El | siete ED | Giitewi ED ViumcOMuedalcvem ES veleectroncatehenn El | vmotieiscain El | andi feiss oF 6 Dffjessp( vorme o: terancates prism’) Height oF e: ‘The teiangle vith an ares of 2/,000 and 2.000, 7.000, and €.c0 Sop swe SEE 08 eel 2 p= tngnn('arsa ov rhs ase trisngie: y+ Dra eee 40 be - inpacy Jesse oF bi"); $3 - inpacy!Soosht oF c:')) BV = Re (nien2ens)/3; 8 KyeiaeE i The teieuste with au area of 4.98 cud $.3£, $.3f, aud $.52 units es Uid beivlils \u"/RpML,M2,US) + 9 fprinte|'ziv= a volume of $.5f cu-units. \a"¥) Editor File Edit View Debug Run Help K@-ShS oe Fx Oe Bieacd (Prism.m [=] VolumeOfSphericalCap.m { AnnuityAndFuturePrice.m [) —ClockTime.m [") ‘ArithmeticOrGeometric.m [E) Command Windaw >> ArithmeticOrGeometric Geometric or Arithmetic Series First terms Second term:10 Third term:15 Wr arivhmetic 1) disp('Geometric or Arithmetic Series") 2 al = input('First term:"); 3 a2 = input(*Second term:'); 4 a3 = imput('Third term:'); 5 6 arithl = al-a2; 7 arith? = a2-a3; 8 geoml = a2/al; 9 geom2 = a3/a2; 10 11 Gjif (arithl == arith2) 12 if (al == a2) 13 disp('The series is neither arithmetic nor geometric.') 14| else 15 disp('Arithmetic'); 16 benaif 17 | elseif (geoml == geom2) 18 disp('Geometric'); 19| else 20 disp('The series is neither arithmetic nor geometric.') a1 Lenair Editor ex File Edit View Debug Rur Help 7 H&- ShHS\9 Ja ate aos 7 ameOfphericalCap.m [J __AnnuityAndFuturePrice.m [5] __CleckTime.m [=] __ArithmeticGrGeometric.m [5 T[4iep(‘Neh Term in an Arirhmetic or Geometris Sequence’) 2 (q = Anput('What is the sequence? for Arithmetic for Geometric:','s"); 3 4EJswitch ta) s]} case ‘2° é al = input ('First tern:'); 7 d= input ('Conmon difterence:'); 8 nth = input (/Tezm pos:tion:')+ 8 n= al+d*(nth-l); 10] case ‘6° a al = input ('First tern:'); a2 x = Anput (‘Common ratio:'): 13 nth = input (\Tezm pos:tion:')+ a4 n= altr*(n-i); as lena 16 [fprint®|'The Neh term of the series is $f \a',n) >> ArithmeticOrGeometric Geometric or Arithmetic Series Command Window >> NehTerm Neh Term in an Arithmetic or Geometric Sequence What is the sequence? for Arithmetic for Geometric: First term:5 Nitem.m GJ 4) conmon cifterence:15 Term position: 58 Ihe Nth term of the series is 860.000000 >I