How do I convert a value from a cell array into an integer?
Afficher commentaires plus anciens
My problem is when I read one cell from table, for example 5, I need to convert this in integer value.
I try cell2mat function, but this function converts in matrix form and when I want to multiply it, it gets matrix but I only need a scaler:
d=5 (from the table)
e=cell2mat(d)
f=e*1 there i don't get 5, I get 53.
That is a problem for me.
1 commentaire
David Young
le 2 Mar 2011
Please could you show a few lines of code that illustrate the problem? It should be possible to cut and paste the code from your question into MATLAB and replicate the result.
Réponse acceptée
Plus de réponses (1)
Andreas Goser
le 2 Mar 2011
In MATLAB, also a scalar is a matrix - a 1x1 matrix.
In MATLAB the default data type is DOUBLE - so even if you assign
d=5;
the internal representation will not be exact 5. But you can work with integers data types see e.g. UINT16.
Catégories
En savoir plus sur Data Type Conversion dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!