How to do interpolation

1 vue (au cours des 30 derniers jours)
Mekala balaji
Mekala balaji le 8 Mar 2018
Commenté : Mekala balaji le 9 Mar 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,

Réponse acceptée

Bob Thompson
Bob Thompson le 8 Mar 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 commentaire
Mekala balaji
Mekala balaji le 9 Mar 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));

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Data Type Conversion dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by