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,

Risposte (2)

Matt J
Matt J il 15 Feb 2016
Modificato: Matt J il 15 Feb 2016
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 il 15 Feb 2016
Modificato: Andrei Bobrov il 15 Feb 2016
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 Commenti

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!!
If you can please tell me all the code and also the plot function I'd be grateful
Andrei Bobrov
Andrei Bobrov il 15 Feb 2016
Modificato: Andrei Bobrov il 15 Feb 2016
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);
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?
my typo, corrected
Hi, Thank you for your answer , but this is what I found .. Any further help?

Accedi per commentare.

Categorie

Scopri di più su Interpolation in Centro assistenza e File Exchange

Richiesto:

il 15 Feb 2016

Commentato:

il 15 Feb 2016

Community Treasure Hunt

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

Start Hunting!

Translated by