{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

class7a_matlab_activities_engr195

# class7a_matlab_activities_engr195 - ENGR 195(II Spring 2010...

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

ENGR 195(II) – Spring 2010 Activity 1 Class 7a Activity 1 – Simple while…end Loop to Add Elements of a Vector (Estimated Time: 15 minutes) In this exercise, you and a partner will practice using a while…end structure to add the elements of a simple array. 1. Open function_header_template.m in the MATLAB editor and re-save as vector_element_sum.m 2. Draw a flowchart that will show the process for calculating the sum of all the elements in any given vector up to, but not including, an element set to -1. It will be assumed that at least one element in the vector is set to -1. 3. Using the flowchart above, write a function within MATLAB. Given any vector of any length, your function must compute the sum of the elements of the vector as described in Step 2. Your function output should be the sum of the appropriate elements of the vector and the number of elements used in the summation. Note : You are not allowed to use MATLAB’s built-in function sum() .

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}