interpolation between two curves

Hi, I'd like to do an interpolation to draw three curves between curves of 900 and 1100K. the curves I need are at 950,1000,1050K. thanks,

답변 (2개)

Matt J
Matt J 2016년 2월 15일
편집: Matt J 2016년 2월 15일

0 개 추천

INTERP1 should work well here,
A =[ NaN 900 1100 1500
-2 -4.4175 -5.1954 -6.1525
-1 -4.3845 -5.186 -6.1478
-0.02 -4.0357 -5.186 -6.1525
0 -2.0603 -5.1624 -6.1525
0.02 -1.2729 -5.1389 -6.1525
0.04 -1.0136 -5.0776 -6.1525
0.06 -0.88162 -4.9408 -6.1525
0.08 -0.7779 -4.2667 -6.1525
1 -0.70718 -3.1823 -6.1525
1.02 -0.69304 -2.923 -6.1289
1.06 -0.65061 -2.6873 -6.0346
1.08 -0.64589 -3.088 -5.7753
2 -0.63175 -2.5694 -5.219
2.02 -0.61289 -2.5459 -4.9267
2.06 -0.61289 -2.5223 -4.6674
3 -0.61289 -2.4846 -4.5495]
T=[900,950,1000,1050,1100,1500];
Anew =[[nan,T]; [A(2:end,1),...
interp1([900,1100,1500],A(2:end,2:end).',T).']];
Andrei Bobrov
Andrei Bobrov 2016년 2월 15일
편집: Andrei Bobrov 2016년 2월 15일

0 개 추천

Please use griddedInterpolant.
Let A your data:
A =[ NaN 900 1100 1500
-2 -4.4175 -5.1954 -6.1525
-1 -4.3845 -5.186 -6.1478
-0.02 -4.0357 -5.186 -6.1525
0 -2.0603 -5.1624 -6.1525
0.02 -1.2729 -5.1389 -6.1525
0.04 -1.0136 -5.0776 -6.1525
0.06 -0.88162 -4.9408 -6.1525
0.08 -0.7779 -4.2667 -6.1525
1 -0.70718 -3.1823 -6.1525
1.02 -0.69304 -2.923 -6.1289
1.06 -0.65061 -2.6873 -6.0346
1.08 -0.64589 -3.088 -5.7753
2 -0.63175 -2.5694 -5.219
2.02 -0.61289 -2.5459 -4.9267
2.06 -0.61289 -2.5223 -4.6674
3 -0.61289 -2.4846 -4.5495]
[X,Y] = ndgrid(A(2:end,1),A(1,2:end));
F = griddedInterpolant(X,Y,A(2:end,2:end),'cubic');
use:
x = 0; % log(P)
y = 1000; % T = 1000 K
out = F(x,y)

댓글 수: 6

rana saleh
rana saleh 2016년 2월 15일
Thank you ur answer. but, when I tried to replace x and Y such that F= giddedInterpolant(0,1000,A(2:end,2:end),'cubic');
it gives me message: The size of the grid point arrays should match the size of the value arrays!!
rana saleh
rana saleh 2016년 2월 15일
If you can please tell me all the code and also the plot function I'd be grateful
Andrei Bobrov
Andrei Bobrov 2016년 2월 15일
편집: Andrei Bobrov 2016년 2월 15일
Example (full code):
A =[ NaN 900 1100 1500
-2 -4.4175 -5.1954 -6.1525
-1 -4.3845 -5.186 -6.1478
-0.02 -4.0357 -5.186 -6.1525
0 -2.0603 -5.1624 -6.1525
0.02 -1.2729 -5.1389 -6.1525
0.04 -1.0136 -5.0776 -6.1525
0.06 -0.88162 -4.9408 -6.1525
0.08 -0.7779 -4.2667 -6.1525
1 -0.70718 -3.1823 -6.1525
1.02 -0.69304 -2.923 -6.1289
1.06 -0.65061 -2.6873 -6.0346
1.08 -0.64589 -3.088 -5.7753
2 -0.63175 -2.5694 -5.219
2.02 -0.61289 -2.5459 -4.9267
2.06 -0.61289 -2.5223 -4.6674
3 -0.61289 -2.4846 -4.5495]
[X,Y] = ndgrid(A(2:end,1),A(1,2:end));
F = griddedInterpolant(X,Y,A(2:end,2:end),'cubic');
log_P = -3:.5:3; % log(P)
T = 900:50:1100;
[P,T_arr] = ndgrid(log_P,T);
out = F(P,T_arr);
plot(log_P(:),out);
rana saleh
rana saleh 2016년 2월 15일
Thank you so much for your answer. I made a printscreen of applying the code. I found all the curves are straightlines? I don't know what is the wrong?
Andrei Bobrov
Andrei Bobrov 2016년 2월 15일
my typo, corrected
rana saleh
rana saleh 2016년 2월 15일
Hi, Thank you for your answer , but this is what I found .. Any further help?

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

카테고리

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

질문:

2016년 2월 15일

댓글:

2016년 2월 15일

Community Treasure Hunt

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

Start Hunting!

Translated by