This preview shows pages 1–14. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: 1 CS113 Introduction to Computing for Engineers Logical Operators and Conditional Statements 2 Programming in Matlab 3 Programming in Matlab 4 Programming in Matlab 5 Programming in Matlab 6 Programming in Matlab 7 Programming in Matlab 8 Programming in Matlab 9 Programming in Matlab 10 Programming in Matlab 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) 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! 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 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...
View Full
Document
 Fall '10
 PhillipRegali

Click to edit the document details