EngE_1114_HW5 - 12:20 M | 1) Given: x EngE 1114 HW5 | 6...

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

View Full Document Right Arrow Icon
1) Given: x Required: Flowchart, MatLab code, sample runs Relationships: y = 1/(2-3x) , y = (x+3) 1/3 Solution: Start INPUT .x IF .x < -3 .y = 1/(2-3x) .y = (x+3) 1/3 OUTPUT .y Stop % This function will return a function of 'y =' when % provided with value of 'x'. % Call statement: [y]=step_function(x) function  [y]=step_function(x) if  x<-3;     y=1./(2-3.*x); else     y=(x+3).^(1/3); end >> [y]=step_function(-10.5) y = 0.0299 >> [y]=step_function(-3) y = 0 >> [y]=step_function(.5) y = 1.5183 12:20 M | EngE 1114 HW5 | 6 February 2006 | Konzik, Kit | /
Background image of page 1

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

View Full DocumentRight Arrow Icon
2) Given: Required: Flowchart, MatLab Code, Sample runs Relationships: if P>=(H+15) and E>=(M+10), G = (P+E)/2, else G = (P+H+M+E)/4   % This function will return semester grade (G) when given:  % the homework grade (H), the project grade (P), the midterm grade, % and the exam grade (E). Call statement: semester_grade H = input ( 'Enter the homework grade of the student:   ' ); P = input ( 'Enter the project grade of the student:    ' ); M = input ( 'Enter the midterm grade of the student:   ' ); E = input ( 'Enter the exam grade of the student:    ' ); if  P>=(H+15)& E>=(M+10);     G=(P+E)/2;     fprintf( 'The semester grade of the student is %.2f\n' ,G); else     G=(P+H+M+E)/4;     fprintf( 'The semester grade of the student is %.2f\n' ,G); end   >> semester_grade Enter the homework grade of the student:   95 Enter the project grade of the student:    80
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 7

EngE_1114_HW5 - 12:20 M | 1) Given: x EngE 1114 HW5 | 6...

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

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