Answered step by step
Verified Expert Solution
Question
1 Approved Answer
5) Write Matlab expressions to extract only the elements at odd positions in a vector (i.e. the 1st, 3rd, 5th, 7th..., elements of the
5) Write Matlab expressions to extract only the elements at odd positions in a vector (i.e. the 1st, 3rd, 5th, 7th..., elements of the vector), regardless of the length of the vector. Make sure your expression can work on vectors with odd or even number of elements. 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 in Matlab command window: >>OrderData=[25.3,18,14.0,82,43.0,17,22.5,33,21.5,35,9.5,112,65.2,35]; As an example, the first product is priced at $25.30 per unit and 18 of it are ordered; the second item is priced at $14.0 per unit and 82 are ordered, and so on. Write Matlab 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. Note: you cannot "manually" type the numbers to create two vectors. You have to use Matlab code to create the new vectors based on the original vector. (2) use the array multiplication operator to create a new vector, storing in this new vector the total price for every product.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started