prob1 - vec1 = data(end:-1:6), set(1:4) % Since the end...

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

View Full Document Right Arrow Icon
% Script Name: prob1 % Script Variables: % 1. vec1 (double) - a vector with elements of "data" and "set" % 2. vec2 (double) - the vector "data" in reverse % 3. vec3 (double) - a vector of numbers from data that are less than 2 % and greater than 8 % 4. vec3length (double) - the length of vec3 % 5. vec4 (double) - a vector of numbers from data that are between 4 and % 8.5. % 6. vec4sum (double) - the sum of the vector "vec4". % 7. vec5 (double) - the scalar product of "data" and "set". % 8. dataAvg - a weighted mean of "data" using "set" as weights. % 9. newData (double) - "data" with every element greater than 5 set to -1 data = 10*rand(1,10); % DO NOT CHANGE THIS LINE set = [1 3 2 1 2 3 1 2 1 2]; % DO NOT CHANGE THIS LINE
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: vec1 = data(end:-1:6), set(1:4) % Since the end started from 10, to make % last 5 elements from 10, we need to count 6 times(such as 10,9,8,7,6) . vec2 = data(end:-1:1) % reverse the data from the back to front by using % colon operator. vec3 = data (data> 8 | data<2) % I used value of (or) operator. vec3length = length(vec3) vec4 = data(data>4 & data< 8.5) % I used valus of (and) operator vec4sum = sum(vec4) vec5 = [data .* set] % multiply data and set each by elements dataAvg = sum(vec5)/sum(set) % to get an average, I devided the total added number of vec5 by summed number of set newData = [data]; newData(data>5) = -1...
View Full Document

This note was uploaded on 11/10/2009 for the course CS 1371 taught by Professor Stallworth during the Fall '08 term at Georgia Institute of Technology.

Ask a homework question - tutors are online