>> C = [{1} {2} ; {'@CF'} {2}] C = [ 1] [2] '@CF' [2] >> whos C Name Size Bytes Class Attributes C 2x2 478 cell
How to convert C to double so that:
C
double
>> C C = 1 2 NaN 2
I tried str2double(C) . It returns:
str2double(C)
NaN NaN NaN NaN
Find numerical values isnumeric , query cellfun . Use this with logical indexing to extract numeric values:
C = [{1} {2} ; {'@CF'} {2}]; isnum = cellfun(@isnumeric,C); result = NaN(size(C)); result(isnum) = [C{isnum}];
C = [{1} {2} ; {'@CF'} {2}] C = [ 1] [2] '@CF' [2] D = cellfun(@isnumeric,C); C(~D)={nan} C = [ 1] [2] [NaN] [2] cell2mat(C) ans = 1 2 NaN 2
Well, you have mixed data types here, so there is no very direct way to do this.
The easiest way I can think of if you know exactly where you want it - just use cell2mat
cell2mat
IE: cell2mat(C(1,1)) returns 1 as double.
cell2mat(C(1,1))
Source: https://habr.com/ru/post/920700/More articles:Java Eclipse: programmatically import plugins and snippets - javaCannot create php str_replace () to remove comma - stringdjango tastypie: getting additional m2m values ββusing an intermediate model - djangocheck stored procedure in MySql Workbench - mysqlHaskell Parsec Parser for the meeting [...] - parsingreading blob image from MySQL database - c #How can I compete with xcopy speed? - windowsliteral or permanent as part of a composite key in EF code - entity-frameworkWhy is my table size larger than 4 times larger than expected? (Strings * bytes / string) - mysqldispatch_async and [NSURLConnection sendSynchronousRequest] - iosAll Articles