Fit a curve so that a part of it is the same as another curve

1 view (last 30 days)
I have a 1d array 'a' and a 1d array 'b'.
'a' is a length m and 'b' is a length n, where m>n.
I want to transform the array 'a' such that
a(1:n)=b
but also such that
a(n+1:m)
is also transform, i.e. so that the transformation is performed to the full array 'a' in matlab.
Is this possible in Matlab?
  2 Comments
Guillaume
Guillaume on 13 Mar 2019
It's really not clear what you want to go in a(n+1:m). Can you explain it better. An actual example would be help:
a = 1:10; %example input
b = [2 4 6 8]; %example input
newa = [2 4 6 8 ? ? ? ? ? ?] %please fill in the ?
Unai De Francisco
Unai De Francisco on 13 Mar 2019
In the case
a = 1:10; %example input
b = [2 4 6 8]; %example input
newa = [2 4 6 8 ? ? ? ? ? ?] %please fill
I would like it to be filled by
newa = [2 4 6 8 10 12 14 16 18 20]

Sign in to comment.

Accepted Answer

Star Strider
Star Strider on 13 Mar 2019
Edited: Star Strider on 13 Mar 2019
I am not certain what you want to do. The two functions that are most likely to give you the desired resultl are linspace (link) and interp1 (link). You will probably need to use both of them together.
EDIT —
With the new information, use interp1:
a = 1:10;
b = [2 4 6 8];
newa = interp1((1:4), b, a, 'linear', 'extrap')
producing:
newa =
2 4 6 8 10 12 14 16 18 20

More Answers (0)

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!