Filter löschen
Filter löschen

How to do interpolation

1 Ansicht (letzte 30 Tage)
Mekala balaji
Mekala balaji am 8 Mär. 2018
Kommentiert: Mekala balaji am 9 Mär. 2018
Hi, I have below cell array data:
Category Player1 Player2 Time
Category1 A B 10
Category1 T P 12
Category1 A T 23
Category1 T B 46
Category2 U L 51
Category2 O C 51
Category2 G J 71
Category2 P X 58
Category2 D F 69
I Want to calculate the score by each category separately, Maximum score is 100 & minimum score is 1
For Category1, the player pair (pair is: Player1 -->Player2) has lesss time will get highest score
1. Player pair having Minimum time score will be 100(Player A-->B)
2. Player pair having Maximum time score will be 1(Player T-->B)
and then interpolated for other player pairs.
For Category2:
1. U-->L & O-->C will get score 100
2. G-->J will get score 1
3. Other player pairs will be interpolated
Many thanks in advance for your kind help,

Akzeptierte Antwort

Bob Thompson
Bob Thompson am 8 Mär. 2018
I would suggest making a new array to set your highest and lowest values. Then you can use the interp1() function. https://www.mathworks.com/help/matlab/ref/interp1.html
interparray(1,:) = [100, max(data(:,4))];
interparray(2,:) = [1,min(data(:,4))];
for k = 1:size(data,1);
data(k,5) = interp1(interparray(:,2),interparray(:,1),data(k,4));
end
Obviously the indexing for this bit is set up for a regular double array, while it appears you have a table, but just adjust the indexing and the concept should still work fine.
  1 Kommentar
Mekala balaji
Mekala balaji am 9 Mär. 2018
I tries as below:
clc;
[~,~,dataTemp] = xlsread('Interpolation_Input.xlsx');
data=dataTemp(2:end,:);
interparray(1,:) = [100, max(cell2mat(data(:,4)))];
interparray(2,:) = [1,min(cell2mat(data(:,4)))];
for k = 1:size(data,1)
data(k,5) = interp1(interparray(:,2),interparray(:,1),data(k,4));
end
It give below error:
Error using interp1 (line 171) Inputs must be floats, namely single or double.
Error in InterpolationRCP (line 7) data(k,5) = interp1(interparray(:,2),interparray(:,1),data(k,4));

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Data Type Conversion finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by