Borrar filtros
Borrar filtros

Of Cell Arrays & Sort

1 visualización (últimos 30 días)
RDG
RDG el 6 de Sept. de 2012
Greetings,
for i=1:5
x{i}=i
end
for j=1:7
y{j}=j
end
merge_twocell = [x y]
Now say I have a variable, select_var and I want to select the lowest 3 values from x and 4 lowest values from y, how can I achieve this?
P/S I'm avoiding using cell2mat, sort the elements, then retrieve what I want. Is there a more direct approach?

Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 6 de Sept. de 2012
Editada: Azzi Abdelmalek el 6 de Sept. de 2012
x1=sortrows(x);y1=sortrows(y);
x_min=x1(1:3)
y_min=y1(1:4)
  3 comentarios
Azzi Abdelmalek
Azzi Abdelmalek el 6 de Sept. de 2012
Editada: Azzi Abdelmalek el 6 de Sept. de 2012
I did'nt see it was a cell, Now I use sortrows instead of sort
x1=sortrows(x);y1=sortrows(y);
x_min=x1(1:3)
y_min=y1(1:4)
RDG
RDG el 6 de Sept. de 2012
Oh, yes yes. Sorry. Thank you very much!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Characters and Strings en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by