Question
Inputs: (double) A 1xN vector to be inserted into odd indices (double) A 1xN vector to be inserted into even indices Outputs: 1. (double) A
Inputs:
-
(double) A 1xN vector to be inserted into odd indices
-
(double) A 1xN vector to be inserted into even indices
Outputs:
1. (double) A 1x2N vector of your compiled data
Background:
You are a brand new data scientist and have just received your first project: you must use MATLAB to create a data set to be presented at next weeks conference. The only problem is that the researcher you are partnered with gave you data thats all out of whack!
Function Description:
You are given two vectors of the same length that must be sorted and then combined. The first vector you are given should be sorted in ascending order. The second vector should be sorted so that its new order follows that of the first (i.e. if the 4th index in the first vector becomes the 1st index after sorting, the 4th index in the second vector should also become the 1st index after sorting). Next, combine your two sorted vectors into a single vector of length 2N, where the odd indices are filled with values from the first vector and the even indices are filled with values from the second vector.
Example:
data = dataMixer([2 7 1 9], [5 6 3 1]); data [1 3 2 5 7 6 9 1]
Hints:
What does each output of sort() give you?
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