How to do interpolation
조회 수: 1 (최근 30일)
이전 댓글 표시
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
채택된 답변
Bob Thompson
2018년 3월 8일
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.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!