{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

LECTURE_7_CS113_2010 - CS113 Introduction to Computing for...

Info icon This preview shows pages 1–14. Sign up to view the full content.

View Full Document Right Arrow Icon
1 CS113 Introduction to Computing for Engineers Logical Operators and Conditional Statements
Image of page 1

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

View Full Document Right Arrow Icon
2 Programming in Matlab
Image of page 2
3 Programming in Matlab
Image of page 3

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

View Full Document Right Arrow Icon
4 Programming in Matlab
Image of page 4
5 Programming in Matlab
Image of page 5

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

View Full Document Right Arrow Icon
6 Programming in Matlab
Image of page 6
7 Programming in Matlab
Image of page 7

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

View Full Document Right Arrow Icon
8 Programming in Matlab
Image of page 8
9 Programming in Matlab
Image of page 9

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

View Full Document Right Arrow Icon
10 Programming in Matlab
Image of page 10
11 Programming Example #1 1. Problem Definition Write a Matlab function file that computes the average grade based on a vector of test grades entered by the user. If the student did not pass the class (i.e. average grade < 60) then display the message “The student did not pass the course.” 2. Problem Analysis User Input: vector of numbers that represent test grades User Output: average test grade and message if the student did not pass the course Equations: Average = (sum of test grades) / (number of exams)
Image of page 11

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

View Full Document Right Arrow Icon
12 Programming Example 3. Develop Algorithm (processing steps to solve problem) Output to the user the average grade User inputs a vector of test grades. Assign that input vector the variable “grades” Determine the number of exams (Nexams) Compute the average grade AverageGrade=sum(grades)/Nexams Is Average<60? yes Display message “Student failed the class!” no
Image of page 12
13 Programming Example #1 function [ave_grade]=calc_grade(grades) % function [ave_grade]=calc_grade(grades) % This function computes the average grade for an input % vector of exam grades % Inputs: grades = vector of exam grades % Outputs: ave_grade = scalar of the average exam grade % % Mark Mirotznik, 9-18-07 N_exams=length(grades); % determine the number of exams
Image of page 13

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

View Full Document Right Arrow Icon
Image of page 14
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern