Convert cell to matrix

1 次查看(过去 30 天)
Martin Park
Martin Park 2013-10-6
回答: Jan 2013-10-6
I have the following {'128' '256' '157' '54'} How can I convert it to a numeric matrix for example 128 256 157 54

采纳的回答

Walter Roberson
Walter Roberson 2013-10-6

更多回答(1 个)

Jan
Jan 2013-10-6
Faster than str2double:
C = {'128' '256' '157' '54'};
S = sprintf('%s*', C{:});
D = sscanf(S, '%g*');

类别

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

Community Treasure Hunt

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

Start Hunting!

Translated by