Fractions after tabulated a ranking

Hello guys,
i have two Matrices tbl1 and tbl2 that you can see below.
My Goal is to create a table or Matrix that gives me the fractions of tbl1 divided by tbl2.
So the final Matrix or table should be a new Matrix that gives me the fractions from tbl1 to tbl2 with a ranking(Ordered Descending).
Can anyone of you please help me ? :)
Thanks

 Respuesta aceptada

the cyclist
the cyclist el 15 de Nov. de 2015
I am not 100% sure I understand what you mean by "the fractions", but the solution below should at least get you some of the components of the solution you need:
tbl1 = {'IT', 7,36.8421;
'GR', 3,15.7895};
tbl2 = {'DE', 18, 18.3673;
'IT', 13, 13.2653;
'GR', 4, 4.0816};
[tf,loc] = ismember(tbl1(:,1),tbl2(:,1));
ratio = cell2mat(tbl1(:,[2 3]))./cell2mat(tbl2(loc,[2 3]));
Notice that I am using the ismember command to locate the strings from tbl1 in tbl2.
I am assuming that each string from tbl1 does appear in tbl2. However, you could used the output tf to check that assumption, and change the code accordingly.

Más respuestas (0)

Categorías

Más información sobre Interactive Control and Callbacks en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 15 de Nov. de 2015

Respondida:

el 15 de Nov. de 2015

Community Treasure Hunt

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

Start Hunting!

Translated by