Problem 42992. S-T-R-E-T-C-H I-T O-U-T
You will be given a row of numbers (x), and a single number (n). Your job is to write a script that will stretch out the row of numbers, putting n numbers between each of the numbers in x. The numbers you put in x will be linearly interpolated.
For example, if x=[1 5 2 4 3] and n=1, your output should be:
y=[1 3 5 3.5 2 3 4 3.5 3]
There is n=1 number between all of the original values of x, and the new values are linearly interpolated from the original values of x:
- 1 --> 3 --> 5
- 5 --> 3.5 --> 2
- 2 --> 3 --> 4
- 4 --> 3.5 --> 3
Solution Stats
Solution Comments
Show commentsProblem Recent Solvers77
Suggested Problems
-
Make the vector [1 2 3 4 5 6 7 8 9 10]
52290 Solvers
-
Find common elements in matrix rows
2708 Solvers
-
What is the distance from point P(x,y) to the line Ax + By + C = 0?
552 Solvers
-
1170 Solvers
-
11060 Solvers
More from this Author80
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!