Question on using interpolate function

4 ビュー (過去 30 日間)
Deepa Maheshvare
Deepa Maheshvare 2020 年 1 月 28 日
コメント済み: Deepa Maheshvare 2020 年 1 月 28 日
I've the following
x = [1 2 3 4 5 6];
data = [0.1 0.2 0.3 0.4 0.4 0.4];
vq1 = interp1(data,x,0.4)
I want to find the x value at which data has 0.4 (first occurence).
I used interpolate. But the following error occurS
The grid vectors must contain unique points.
Any suggestions on how to proceed when data doesn't contain uniqe values will be helpful
  1 件のコメント
Deepa Maheshvare
Deepa Maheshvare 2020 年 1 月 28 日
I'm still expecting answers for this post. Unfortunately, the following suggestions didn't help.

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

回答 (2 件)

KSSV
KSSV 2020 年 1 月 28 日
Use logical indexing:
x = [1 2 3 4 5 6];
data = [0.1 0.2 0.3 0.4 0.4 0.4];
vq1 = x(abs(data-0.4)<10^-5)
  1 件のコメント
Deepa Maheshvare
Deepa Maheshvare 2020 年 1 月 28 日
編集済み: Deepa Maheshvare 2020 年 1 月 28 日
I'm looking for an interpolation function. It may happen that Ive to check for a value of 0.45 that is not present in data

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


Bhaskar R
Bhaskar R 2020 年 1 月 28 日
"I want to find the x value at which data has 0.4 (first occurence)."
match_loc = find(data == 0.4);
val = x(x == match_loc(1)); % first occurance of 0.4
  1 件のコメント
Deepa Maheshvare
Deepa Maheshvare 2020 年 1 月 28 日
What if I have to check for 0.45?

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

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by