# Interpolation between three sets of data

조회 수: 11 (최근 30일)
Sami Al-Abbar 2015년 5월 6일
댓글: Sami Al-Abbar 2015년 5월 7일
I have three Arrays(Column Vector?) of Speed vs. Position for three different voltages (9V, 13.5V and 16V). Each array contains a speed for every position (2387 values). I would like to make a lookup table with the position and voltage as inputs and the speed value as output. For that, I would like to interpolate the speed vs. position arrays for the voltages in between the three that I already have. That should result in speed vs position arrays for 9v, 10v, 11v - 16v. Is this possible?
The interpolation methods in the help section only show how to interpolate along the x-axis (in this case the Position values) while in my case, I have three sets of data separated by voltage and want to interpolate in between these sets.
Perhaps a multidimensional array could be used?
Any help would be greatly appreciated.

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

### 채택된 답변

Andrei Bobrov 2015년 5월 6일
편집: Andrei Bobrov 2015년 5월 6일
Let your data S (Speed) V (voltages):
V = [9, 13.5, 16];
S = randi(20,10,3);
Solution:
n = 1:size(S,1);
[ii,jj] = ndgrid(n,V);
F = griddedInterpolant(ii,jj,S,'cubic');
[i2,Vnew] = ndgrid(n,[9 10 11 16]);
out = F(i2,Vnew);
or with griddata:
n = 1:size(S,1);
[ii,jj] = ndgrid(n,V);
[i2,Vnew] = ndgrid(n,[9 10 11 16]);
out = griddata(ii,jj,S,i2,Vnew);
##### 댓글 수: 5이전 댓글 3개 표시이전 댓글 3개 숨기기
Andrei Bobrov 2015년 5월 7일
n = 1:size(SLT,1);
[i0,j0,k0] = ndgrid(n,[9,13.5,16],[-20,25,85]);
S = cat(3,SLT,SRT,SHT);
[i1,j1,k1] = ndgrid(n,9:.5:16,-20:85);
Vout0 = griddatan([i0(:),j0(:),k0(:)],S(:),[i1(:),j1(:),k1(:)]);
Vout = reshape(Vout0,size(i1));
Sami Al-Abbar 2015년 5월 7일
Thank you very much!
I spent most of yesterday afternoon and this morning trying to figure this out by reading the help section and using trial and error.
I got close enough to know the griddatan needed a 2387x15x106 values but I didnt know how to use ndgrid to achieve this. Thanks again for your solution.

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

### 추가 답변 (1개)

Alka Nair 2015년 5월 6일
Hi, Interpolation can also be done for multidimensional data. Please refer to the documentation page for INTERP2 and INTERP3 at the following locations:
and

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

### 카테고리

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

### Community Treasure Hunt

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

Start Hunting!

Translated by