Sort elements in cell array in descending order

7 visualizaciones (últimos 30 días)
Panos Kerezoudis
Panos Kerezoudis el 11 de Mayo de 2023
Comentada: Panos Kerezoudis el 11 de Mayo de 2023
Hi!
I hava a cell containing three row vectors and I would like to sort each vector in descending order.
Other than using a loop, is there a way to do this with the cellfun function? bc it automatically does it in ascending order.
This is the code that I used using cellfun.
thank you!
new_cell_array = cellfun(@sort, cell_array, 'UniformOutput', false);

Respuesta aceptada

Stephen23
Stephen23 el 11 de Mayo de 2023
fun = @(v) sort(v,'descend');
new_cell_array = cellfun(fun, cell_array, 'UniformOutput', false);
  1 comentario
Panos Kerezoudis
Panos Kerezoudis el 11 de Mayo de 2023
perfect thank you!
so for my learning, @(v) enables me to use/specify an existing function prior to inputting into cellfun?

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Matrices and Arrays en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by