10) A vector v stores for several employees of the Green Fuel Cells Corporation
ID: 3650131 • Letter: 1
Question
10) 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 employeeExplanation / Answer
Please rate...
Save the file as "totalpay.m" in the matlab working directory:
===========================================================
function [ vtp ] = totalpay(vv)
l=length(vv);
Hours=[];
Rate=[];
c=1;
for i=1:2:l
Hours(c)=vv(i);
c=c+1;
end
c=1;
for i=2:2:l
Rate(c)=vv(i);
c=c+1;
end
Hours
Rate
TotalPay=Hours.*Rate
end
============================================================
Sample Output:
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.