Please use Matlab!!!
6) A vector OrderData stores a sequence of numbers that represent the unit price and order quantity of several products. The variable can be defined using the following expression: >>OrderData=[33.0,10,40.0,8,20.0,7,28.0,12,10.5,25,7.5,12,15.2,25]; As an example, the first product is priced at $33.0 per unit and 10 of it are ordered; the second item is priced at $40 per unit and 8 are ordered, and so on. Write codes to:
(1) programmingly convert this vector OrderData into two separate vectors, one that stores the unit price and another that stores the order quantity;
(2) use the array multiplication operator to create a new vector, storing in this new vector the total price for every product.
OrderData=[33.0,10,40.0,8,20.0,7,28.0,12,10.5,25,7.5,12,15.2,25]; unit_price = []; order_quantity = []; for i=1:2:length(OrderData) unit_price(1+length(unit_price)) = OrderData(i); order_quantity(1+length(order_quantity)) = OrderData(i+1); end total_price = unit_price.*order_quantity; unit_price order_quantity total_price
Get Answers For Free
Most questions answered within 1 hours.