How to modify number of characters for numeric values in a cell array?
Afficher commentaires plus anciens
Within a cell array, I would like to limit the number of characters allowed in each cell to 6. If the cell has more than 6 characters, I would like to remove the characters off of the end. i.e.
n_raw =
[ 0.023391]
[ 0.31236]
[ 0.0073958]
[ 0.6252]
[ 14.158]
[ 14.159]
[ 0.046701]
[ 0.095463]
to
n_raw =
[ 0.0233]
[ 0.3123]
[ 0.0073]
[ 0.6252]
[ 14.158]
[ 14.159]
[ 0.0467]
[ 0.0954]
5 commentaires
per isakson
le 15 Juil 2017
"number of characters allowed in each cell to 6" are the values in the cells floating point numbers or string characters?
Calabrese
le 15 Juil 2017
per isakson
le 15 Juil 2017
Then the answer is: Not possible!
Calabrese
le 15 Juil 2017
per isakson
le 15 Juil 2017
Why not try?
You have to distinguish between internal representation and what's displayed.
>> cac{1} = 1/3;
cac{2} = 33.3;
cac
cac =
[0.3333] [33.3000]
>> format long
>> cac
cac =
[0.333333333333333] [33.299999999999997]
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Matrices and Arrays dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!