Azzera filtri
Azzera filtri

trimming numbers

4 visualizzazioni (ultimi 30 giorni)
joseph Frank
joseph Frank il 2 Lug 2011
how can I trim numbers in matlab (similar to the left and right functions in excel). For example, if: A=[3829 3620 3714] and i want to get the first two digits: to get B=[38 36 37], how can i do so?

Risposta accettata

Oleg Komarov
Oleg Komarov il 2 Lug 2011
A = [3829 36203 371];
% Robust to different 'lengths'
fix(A ./ 10.^(ceil(log10(abs(A)))-2))

Più risposte (1)

Rick Rosson
Rick Rosson il 2 Lug 2011
Please try the following:
B = floor(A/100);
HTH.

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by