Converting from char to double

118 次查看(过去 30 天)
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!

采纳的回答

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

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Data Type Conversion 的更多信息

产品


版本

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by