clear
close
chr = '0.41 8.24 3.57 6.24 9.27';
%can define formatSpec as vari or stick in function call directly
C = textscan(chr,'%f')
%display it
celldisp(C)
pause
%Read the same character vector, and truncate each value to one decimal digit.
C = textscan(chr,'%3.1f %*1d');
%The specifier %3.1f indicates a field width of 3 digits and a precision of 1. The textscan function reads a total of 3 digits, including the decimal point and the 1 digit after the decimal point. The specifier, %*1d, tells textscan to skip the remaining digit.
%Display the contents of cell array C.
celldisp(C)
pause
filename = 'scan1.dat';
fileID = fopen(filename);
C = textscan(fileID,'%s %s %f32 %d8 %u %f %f %s %f');
fclose(fileID);
whos C
%overfiew of C
C
%Examine the individual entries. Notice that C{1} and C{2} are cell arrays. C{5} is of data type uint32, so the first two elements of C{5} are the maximum values for a 32-bit unsigned integer, or intmax('uint32').
%this pauses after first 2 cells, hit <cr> again
celldisp(C)

pause

%Remove the literal text 'Level' from each field in the second column of the data from the previous example. A preview of the file is shown below.
fileID = fopen(filename);
C = textscan(fileID,'%s Level%d %f32 %d8 %u %f %f %s %f');
fclose(fileID);
C{2}