Q:

A vector v stores for several employees of the Green Fuel Cells Corporation their hours worked one week followed for each by the hourly pay rate. For example, if the variable stores

0

 A vector v stores for several employees of the Green Fuel Cells Corporation their hours worked one week followed for each by the hourly pay rate. For example, if the variable stores

 >> v

v =

33.0000 10.5000 40.0000 18.0000 20.0000 7.5000

that means the first employee worked 33 hours at $10.50 per hour, the second worked 40 hours at $18 an hour, and so on. Write code that will separate this into two vectors, one that stores the hours worked and another that stores the hourly rates. Then, use the array multiplication operator to create a vector, storing in the new vector the total pay for every employee. 

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

>> hours = v(1:2:length(v))

hours =

 33 40 20

>> payrate = v(2:2:length(v))

payrate =

 10.5000 18.0000 7.5000

>> totpay = hours .* payrate

totpay =

 346.5000 720.0000 150.0000

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now