How to separate the integer value of a real number
Mostrar comentarios más antiguos
For example a variable A is calculated as {2.951,5.420,8.062,4.963, .....} I want A to have just the integer values of these real numbers, i.e. A={2,5,8,4,....}
Respuesta aceptada
Más respuestas (1)
TAB
el 26 de Sept. de 2012
A = cellfun(@(x)(fix(x)),A,'UniformOutput', false)
3 comentarios
Jan
el 26 de Sept. de 2012
Anonymous functions in CELLFUN are much slower than functions handles. Does this work:
cellfun(@fix, x,'UniformOutput', false)
TAB
el 26 de Sept. de 2012
A= {1:0.55:1000};
TEST 1
tic
cellfun(@fix,A,'UniformOutput', false);
toc
>> Elapsed time is 0.000161 seconds.
TEST 2
tic
cellfun(@(x)(fix(x)),A,'UniformOutput', false);
toc
>> Elapsed time is 0.000442 seconds.
Categorías
Más información sobre Symbolic Math Toolbox 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!