How to get score of each combination of pairs in each tool

조회 수: 1 (최근 30일)
Mekala balaji
Mekala balaji 2018년 2월 23일
댓글: Mekala balaji 2018년 2월 27일
Hi,
I have score of a different combination of recipe pairs in each tool, now I give available recipes and want to get the score of each possible combination of recipes in each tool,
Score_data:
Tool Pair Score
Tool1 AB 40
Tool1 AS 37
Tool1 AT 11
Tool1 SA 23
Tool1 ST 37
Tool1 TA 39
Tool1 TB 17
Tool1 BA 39
Tool2 BA 23
Tool2 BS 40
Tool2 BT 39
Tool2 SA 36
Tool2 ST 33
Tool2 AS 10
Tool3 AB 11
Tool3 AS 21
Tool3 AT 26
Tool3 BA 38
Tool3 BS 12
Tool3 BT 39
Tool3 ST 21
Tool3 TA 0
Tool4 AB 23
Tool4 BT 40
Tool4 SA 0
Tool4 TB 11
Tool4 AT 40
Tool4 BA 0
Tool4 BS 10
AB means: A-->B pair,AS means A-->S pair etc.
Now I want to get possible score of given recipes in each tool,
New_recipes:
A
B
S
T
D
N
My desired output: If any pair's score not available then it is NA in the desired output.
AB AS AT AD AN BA BS BT BD BN SA SB ST SD SN TA TB TD TN
Tool1 40 37 11 NA NA 39 NA NA NA NA 23 NA 37 NA NA 39 17 NA NA
Tool2 NA 10 NA NA NA 23 40 39 NA NA NA NA 33 NA NA NA 11 NA NA
Tool3 11 21 26 NA NA 38 12 39 NA NA 36 NA 21 NA NA 0 NA NA NA
Tool4 23 NA 40 NA NA 0 10 40 NA NA 0 NA NA NA NA NA NA NA NA
Many thnaks in advance,

채택된 답변

Guillaume
Guillaume 2018년 2월 24일
편집: Guillaume 2018년 2월 24일
Very easily done if your data is in a table, using unstack:
toolscore = readtable('scoredata.txt'); %after saving your example in a text file
unstack(toolscore, 'Score', 'Pair')
  댓글 수: 7
Guillaume
Guillaume 2018년 2월 26일
Well, yes, you commented out the first line, which reads the file into a table. As I wrote in the first line of my answer:
"Very easily done if your data is in a table using unstack"
Get rid of the outdated xlsread and use readtable instead, as per my answer.
Mekala balaji
Mekala balaji 2018년 2월 27일
Sir,
but my scoreInput file will be either in xlsx or csv format,
do I need to preprocess the data such as read data first (from xlsx or csv), then form a table

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Tables에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by