%% Display Error Message
% Create a string and read data from it. When sscanf fails to convert all of the input string, display the error message.
% Starting in R2017a, you can create strings using double quotes.

str = "3.14159 are the first 6 digits of pi"

%
% Convert the number in str. Since str also contains characters that %f cannot match, sscanf returns an error message. sscanf stops processing as soon as it encounters the word 'are' because it cannot be converted to a number.

[A,n,errmsg] = sscanf(str,'%f')

% Copyright 2012 The MathWorks, Inc.