www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/ConvertStringArraysToNumericArraysExample.m

    %% Convert String Arrays to Numeric Arrays
% Starting in R2016b, you can create string arrays using the |string|
% function. You can convert strings to numbers using the |str2double|
% function.
%
% Create a string that represents a number. Convert it to a numeric scalar.
str = string('81470.5')

%%
X = str2double(str)

%%
% Create a string array representing numbers. Convert it to a numeric array
% that is the same size.
str = string({'91.57','95.95','3.57';
              '79.22','65.57','84.91'})
          
%%
X = str2double(str)