How to do interpolation
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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,
0 Kommentare
Akzeptierte Antwort
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
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Logical 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!