Lubnow_Brian_HW_13

Lubnow_Brian_HW_13 - SOLUTION: Part A function...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
12R-CF 11/28/2011 ENGE1114-HW 13 Lubnow, Brian 1/2 PROBLEM STATEMENT: HW 13 Problem 1, learn to create and use function files in MatLab. SOLUTION: K = 0; MIN = 0; MAX = 1000; sumnum = 0; m = 0; Tdif = 0; vn = randi([10,100]); for K = 1:1:vn C = randi(1000); sumnum = sumnum + C; if v > MAX MAX = C; else if C < MIN MIN = C; end V(K) = C; end end avgnum = sumnum / vn; for m = 1:1:vn dif(m)=(V(m)-avgnum)^2; Tdif = dif(m) + Tdif; end div = Tdif/ (vn-1); dev = sqrt(div); fprintf( 'The number of values in the vector is: %.0f\n' , vn) fprintf( 'The average number is: %.0f\n' , avgnum) fprintf( 'The standard deviation of the numbers is: %.2f\n' , dev) fprintf( 'The maximum number is: %.0f\n' , max) fprintf( 'The minimum number is: %.0f\n' , min)
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
12R-CF 11/28/2011 ENGE1114-HW 13 Lubnow, Brian 2/2 PROBLEM STATEMENT: HW 13 problem 2. Use functions and script files to create a MatLab program to analyze triangles and the distance between two points.
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: SOLUTION: Part A function L=DistanceBetween(x1,y1,x2,y2) L=sqrt((x1-x2)^2+(y1-y2)^2); Part B function R=areaoftriangle(a,b,c) s=(a+b+c)/2; R=sqrt(s*(s-a)*(s-b)*(s-c)); Part C x1=input( 'Input x coordinate of point 1: ' ); y1=input( 'Input y coordinate of point 1: ' ); x2=input( 'Input x coordinate of point 2: ' ); y2=input( 'Input y coordinate of point 2: ' ); x3=input( 'Input x coordinate of point 3: ' ); y3=input( 'Input y coordinate of point 3: ' ); a=Fdist(x1,y1,x2,y2); b=Fdist(x2,y2,x3,y3); c=Fdist(x3,y3,x1,y3); area=Farea(a,b,c); fprintf( 'The area of the Triangle is %.2f\n' ,area) Sample Run Input x coordinate of point 1: 3 Input y coordinate of point 1: 4 Input x coordinate of point 2: 5 Input y coordinate of point 2: 6 Input x coordinate of point 3: 9 Input y coordinate of point 3: 12 The area of the Triangle is 8.25...
View Full Document

Page1 / 2

Lubnow_Brian_HW_13 - SOLUTION: Part A function...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online