Question on using interpolate function

조회 수: 1 (최근 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

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by