Converting from char to double

123 vues (au cours des 30 derniers jours)
Uerm
Uerm le 7 Déc 2019
Commenté : Uerm le 12 Déc 2019
Hi,
I have a 1x48 cell where each cell is a Ax1 cell with characters such as (N, (V etc. When I convert to double, I get double('(N')) = [40,78].
How can I for (N and all other characters (they can have multiple letters such as (PVC ) convert it to double and this double value should be one value. What I mean with one value is instead of [40,78], it should end as 4078 for instance. I have attached the cell as a mat file (comments2.mat).
Thanks!

Réponse acceptée

David Hill
David Hill le 7 Déc 2019
This should work for you.
A=[40 78];
A=num2str(A);
A=str2num(A(A~=' '));
  2 commentaires
per isakson
per isakson le 7 Déc 2019
The same basic idea
>> sscanf( sprintf( '%d', double('(N') ), '%d' )
ans =
4078
Uerm
Uerm le 12 Déc 2019
Thanks a lot, David! It works.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Data Type Conversion dans Help Center et File Exchange

Produits


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by