Answered step by step
Verified Expert Solution
Link Copied!

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction to Algorithms

Authors: Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest

3rd edition

978-0262033848

More Books

Students also viewed these Programming questions

Question

What role do hormone levels play in mood?

Answered: 1 week ago

Question

x-3+1, x23 Let f(x) = -*+3, * Answered: 1 week ago

Answered: 1 week ago