Merge two cells into a single cell?
Mostrar comentarios más antiguos
Hello World,
I'm basically trying to find the most frequent column vector of the vertically concatenated matrix of
x=[2 3 4 3 5 4 4]
y=[7 9 8 9 7 3 7]
I tried doing
z=[x;y]
mode(z,2)
But this only gives me the most frequent value for each row. I need the frequent combination ( in my case, 3;9 not 4;7)
So, right now I'm trying to find a way to make a matrix such that I'll get the following using x and y:
w=[27 39 48 39 57 43 47]
How could I do that?
1 comentario
TUD
el 16 de Mzo. de 2014
Respuestas (3)
Mischa Kim
el 16 de Mzo. de 2014
Editada: Mischa Kim
el 16 de Mzo. de 2014
TUD, use
w = str2num(num2str([x' y'], '%-d'))'
2 comentarios
TUD
el 16 de Mzo. de 2014
Mischa Kim
el 16 de Mzo. de 2014
Editada: Mischa Kim
el 16 de Mzo. de 2014
TUD, this should do the job:
x = [25 3 4 3 5 4 4];
y = [ 7 9 8 9 7 3 7];
z = str2num(strcat(num2str(x'),num2str(y')))
z =
257
39
48
39
57
43
47
Jos (10584)
el 16 de Mzo. de 2014
Another option:
x=[2 3 4 3 5 4 4]
y=[7 9 8 9 7 3 7]
[xy,~,ix] = unique([x(:) y(:)],'rows') ;
[~,ix2] = mode(ix)
MyMode = xy(ix2,:).'
1 comentario
TUD
el 20 de Mzo. de 2014
Categorías
Más información sobre Creating and Concatenating Matrices en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!