How can i interpolate 1-D data, whit y especified values?

4 ビュー (過去 30 日間)
camilo utrera
camilo utrera 2022 年 8 月 12 日
コメント済み: camilo utrera 2022 年 8 月 16 日
Dear community
I want my interpolation to contain some specified values:
x = [1 2 3 4 6];
y = x^2;
xx = linspace(x(1),x(end),80)
vq = interp1(x,y,xx,'spline')
Let say that I want that vq contains y = 4.5 (or a set of values), and i have the x* value(s) that do y(x*) = 4.5 ( I alredy know that in this example y = 3.5 is a little off)
Thanks in advance.

採用された回答

the cyclist
the cyclist 2022 年 8 月 13 日
Unless I'm missing something, it sounds like you just want to interpolate x from y, instead of y from x:
x = [1 2 3];
y = [1 4 9];
yq = y(1) : 0.5 : y(end);
xq = interp1(y,x,yq,'spline');
[xq' yq']
ans = 17×2
1.0000 1.0000 1.1875 1.5000 1.3667 2.0000 1.5375 2.5000 1.7000 3.0000 1.8542 3.5000 2.0000 4.0000 2.1375 4.5000 2.2667 5.0000 2.3875 5.5000
  1 件のコメント
camilo utrera
camilo utrera 2022 年 8 月 16 日
Thanks you very much, I think I was a little cofused in how the problem was written.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Find more on Interpolation in Help Center and File Exchange

製品


リリース

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by