Scatter data interpolation of a column matrix

조회 수: 1 (최근 30일)
Debanjan Maity
Debanjan Maity 2019년 1월 30일
댓글: Andrei Bobrov 2019년 1월 30일
say I have two matrix
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
15 24 32 44 51] ;
I want to get throttle values at some specific torque position.
say the torque position points are [10.5;20.4;30.5;40.2;22.4;51.9]
How to do this with interpolation function, i am facing error during running the code
1.jpg
  댓글 수: 3
Debanjan Maity
Debanjan Maity 2019년 1월 30일
Is it a problem if torque data contains NaN.
Debanjan Maity
Debanjan Maity 2019년 1월 30일
The code is following:
throttle= [0 2.5 5 10 15 20 30 40 50 60 65 70 75 80 90 100];
torque=yi;
torquei= rpm_new(:,4);
throttlei = zeros(3622,1) ;
for i = 1:3622
throttlei(i,:) = interp1(torque(i,:),throttle,torquei(i,:)) ;
end
The error is like following:
Error using griddedInterpolant
The grid vectors must contain unique points.
Error in interp1 (line 161)
F = griddedInterpolant(X,V,method);
Error in test_sch_shifting_map (line 64)
throttlei(i,:) = interp1(torque(i,:),throttle,torquei(i,:)) ;
I am also attaching the excel files.

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

채택된 답변

Andrei Bobrov
Andrei Bobrov 2019년 1월 30일
편집: Andrei Bobrov 2019년 1월 30일
T = readtable('torque.xlsx','ReadV',0);
torquei = xlsread('torquei.xlsx');
throttle= [0 2.5 5 10 15 20 30 40 50 60 65 70 75 80 90 100];
T = T{:,:};
d = diff(T,1,2);
ad = cumsum(eps(1e3)*~[d,zeros(size(T,1),1)],2);
Tw = T + ad;
out = cellfun(@(x,y)interp1(x,throttle(:),y),num2cell(Tw',1),num2cell(torquei'));
  댓글 수: 2
Debanjan Maity
Debanjan Maity 2019년 1월 30일
Showing error
Undefined function or variable 'd'.
Error in Untitled (line 5)
ad = cumsum(eps(1e3)*~[d,zeros(size(T,1),1)],2);
Andrei Bobrov
Andrei Bobrov 2019년 1월 30일
My typo, fixed.

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by