How to interpolate based on given column

조회 수: 3 (최근 30일)
Mekala balaji
Mekala balaji 2018년 11월 7일
편집: madhan ravi 2018년 11월 7일
Hi,
I have below array(double), and want to assign 50 for maximum value and 0 for minimum value, and for the rest of the values between maxima and minima interpolation.
0.2
0.8
1.0
1.3
0.8
2.3
4.9
10.0
0.2
5
2.3
8.7
10
In this case,
0.2 -->50
10.0 -->0
for rest of the values, to interpolate between 50& 0.

채택된 답변

Stephen23
Stephen23 2018년 11월 7일
편집: Stephen23 2018년 11월 7일
No need to use interpolation, just some simple, efficient arithmetic:
>> V = [0.2;0.8;1.0;1.3;0.8;2.3;4.9;10.0;0.2;5;2.3;8.7;10]
V =
0.20000
0.80000
1.00000
1.30000
0.80000
2.30000
4.90000
10.00000
0.20000
5.00000
2.30000
8.70000
10.00000
>> Vmin = min(V);
>> Vmax = max(V);
>> 50*(Vmax-V)/(Vmax-Vmin)
ans =
50.00000
46.93878
45.91837
44.38776
46.93878
39.28571
26.02041
0.00000
50.00000
25.51020
39.28571
6.63265
0.00000

추가 답변 (1개)

madhan ravi
madhan ravi 2018년 11월 7일
편집: madhan ravi 2018년 11월 7일
a=[0.2
0.8
1.0
1.3
0.8
2.3
4.9
10.0
0.2
5
2.3
8.7
10]
[~,x1]= max(a)
[~,x2]=min(a)
a(x1)=50
a(x2)=0
Interpolated_values=interp1(a,linspace(a(1),a(end))); %interpolated between 0 and 50

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by