Vector creation with information of other vector

2 次查看(过去 30 天)
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

采纳的回答

Andrei Bobrov
Andrei Bobrov 2012-9-26
编辑:Andrei Bobrov 2012-9-26
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);

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Interpolation 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by