How to work with interpolation function?

I am trying to do the interpolation between given set of data. I used interp1 function but it is showing the error as ''The grid vectors are not strictly monotonic increasing''
A=
290.21
291.22
291.11
290.73
293.03
299
304.92
323.5
323.63
322.93
323.35
327.91
334.71
338.42
354.02
353.05
354
359.45
367.48
368.58
368.28
382.41
B=
0.10855
0.11775
0.12746
0.13738
0.14831
0.16082
0.17539
0.32785
0.35750
0.38682
0.41663
0.44895
0.48715
0.52816
0.69683
0.70275
0.70755
0.71234
0.71765
0.72197
0.72559
0.75153
I write the code like this..
x=0.2:0.1:0.5
D=interp1(B,A,x)
How to solve this problem??
Thanks

댓글 수: 6

Hmm, I don't get an error for the values you gave ...
interp1(B,A,x)
ans =
307.9192 320.1060 323.1157 335.8725
Titus
R7 DR
R7 DR 2015년 2월 19일
Thanks for the reply.
The strange thing is that if I am loading the the data from excel file it is showing error. It is working fine, if I make a column vector by copy & paste from excel.
I dont know the reason. Could you please try to load it from excel and check for the error?
Thanks for your time.
Star Strider
Star Strider 2015년 2월 19일
Your ‘A’ is not strictly monotonically increasing, but ‘B’ is. Your code works for me (in R2014b) as you wrote it. I got the same results Titus did.
R7 DR
R7 DR 2015년 2월 19일
How to deal with interpolation, in this case ‘A’ is not strictly monotonically increasing, but ‘B’.
Star Strider
Star Strider 2015년 2월 19일
The code you posted works. What do you want to do with your data and the interpolation? You have to tell us what the problem is.
Hi
I wrote the code like this, but showing the same error. I am attaching the excel file. could you please check once.
A=xlsread('interpolation.xlsx','sheet1','A:A')
B=xlsread('interpolation.xlsx','sheet1','B:B')
x=0.2:0.1:0.5
D=interp1(B,A,x)
Thanks

댓글을 달려면 로그인하십시오.

 채택된 답변

Titus Edelhofer
Titus Edelhofer 2015년 2월 20일

0 개 추천

Hi,
in your file B67 is equal to B68. Remove one of the lines.
Titus

댓글 수: 2

Titus Edelhofer
Titus Edelhofer 2015년 2월 20일
No, since the data on x are not monotonic. Now it depends on the application, you can e.g. sort the data (using sort or sortrows), if this makes sense.
R7 DR
R7 DR 2015년 2월 20일
Is there any function to deal with the interpolation of these kind of data, becuae I cant modify the data.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Interpolation에 대해 자세히 알아보기

질문:

2015년 2월 19일

댓글:

2015년 2월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by