prob4 HW2

# prob4 HW2 - answer in a variable called"vSum"(c...

This preview shows page 1. Sign up to view the full content.

% Areeje Khalek % 8/23/2009 9:29 PM % Prob4 of hw02 % Script Name: prob4 % Script Variables: % 1. vLength (double) - The length of the vector % 2. vSum (double) - The sum of the elements of the vector % 3. vMean (double) - The mean of the elements of the vector % 4. vProd (double) - The product of the elements of the vector % 5. vMin (double) - The minimum element of the vector % % Problem Statement: % You are given a vector "vec", defined as: % vec = [43 8 1 6 83 53 44 -11 90]; % Using the given "prob4" script, complete the following exercises. You % should not just enter the solution value, and instead use built-in % Matlab functions to calculate the value based on the vector itself. % % (a) Find the length of the vector "vec". Store your answer in a % variable called "vLength". % % (b) Find the sum of the elements in the vector "vec". Store your
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: % answer in a variable called "vSum". % % (c) Find the the mean of the vector "vec". Store your answer in a % variable called "vMean". % % (d) Find the product of the elements in the vector "vec". Store your % answer in a variable called "vProd". % % (e) Find the smallest/minimum element in the vector "vec". Store your % answer in a variable called "vMin". a vec = [43 8 1 6 83 53 44 -11 90]; % DO NOT CHANGE THIS LINE v % calculation of length using length function of matlab vLength = length(vec); v % calculation using sum function of matlab vSum = sum(vec); v % calculation of mean using mean function of matlab vMean = mean(vec); v % calculation of product using prod function of matlab vProd = prod(vec); v % calculation of minimum using the min function of matlab vMin = min(vec);...
View Full Document

## This note was uploaded on 10/22/2009 for the course CS 1371 taught by Professor Stallworth during the Fall '08 term at Georgia Tech.

Ask a homework question - tutors are online