Clear Filters
Clear Filters

Vector creation with information of other vector

2 views (last 30 days)
Hi,
I have a question about the creation of a vector. On one hand, I have two vectors:
m1x= [550 560 562 562 645]
m1y= [0.003 0.0005 0.0008 0.0002 0.012]
And on the other hand, I have another one:
l1x= [560 580 562 546 524]
With m1x and m1y I've done a interpolation and I have values for each number from 550 to 645. I've saved that information in a new vector. The interpolation vector is like this:
a1x= [550 551 552 553 554 555 556 ...]
a2x= [0.002 0.02 0.002 0.06 0.08 0.07 ...]
My purpose is to create another vector and I want to obtain the y values from the l1x vector values (using the results of the interpolation vector). So, for example I want a vector like this:
l1x= [560 580 562 546 524]
l1y (this is the new vector)= [0.005 0.005 (this number is from the vector of interpolation) 0.0008...].
How can I indicate to the code that I want some specific numbers from the interpolation data to the new vector?
Greetings and thanks in advance,
Emma

Accepted Answer

Andrei Bobrov
Andrei Bobrov on 26 Sep 2012
Edited: Andrei Bobrov on 26 Sep 2012
m1x= [550 560 562 562 645];
m1x = m1x+[false, diff(m1x) == 0]*eps(1000);
pp = interp1(m1x,m1y,'linear','pp');
l1x= [560 580 562 546 524];
out = ppval(pp,l1x);

More Answers (0)

Categories

Find more on Interpolation in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!