MATLAB: Interpolation of scatter data of a matrix

interpolation

Say i have a 1*5 matrix known as throttle is [1 2 3 4 5], I have another matrix of torque of 5*5. the corresponding elements for the 6*5 matrix is [10 ;12 ;15; 16; 14 20; 24; 25; 27; 22 30; 32; 34; 35; 36 40; 41; 42 ;46 ;42 50; 55; 54; 53; 52 ].
throttle 1 2 3 4 5
torque 10 20 30 40 50
12 24 32 41 55
15 25 34 42 54
16 27 35 46 53
14 22 36 42 52
i have an another matrix of 7*5 of torque data say [10.2 ;12.3 ;15.4; 16.2;14.7 20.1; 24.5; 25.2; 27.5; 22.4 30.2; 32.4; 34.5; 35.2; 36.8 40.2; 41.4; 42.3 ;46.1 ;42.8 50.2; 55.3; 54.2; 53.7; 52.8 ]. i want to get corresponding throttle positions for corresponding torque steps. through interpolation function how to do this?

Best Answer

Read about interp2
throttle =[ 1 2 3 4 5] ;
torque =[ 10 20 30 40 50
12 24 32 41 55
15 25 34 42 54
16 27 35 46 53
14 22 36 42 52] ;
torquei = [10.2 12.3 15.4 16.2 14.7 ; 20.1 24.5 25.2 27.5 22.4 ; 30.2 32.4 34.5 35.2 36.8 ;
40.2 41.4 42.3 46.1 42.8 ; 50.2 55.3 54.2 53.7 52.8 ] ;
throttlei = zeros(5,5) ;
for i = 1:5
throttlei(i,:) = interp1(torque(i,:),throttle,torquei(i,:)) ;
end
If you have Y coordinate also, you can use interp2