Hello everyone
i was given a script which enables me to extract a normalization value from a data file. the data file consist of a header with two columns and a body with three columns of data. the code is shown below
C = dataread('file', 'test.dat', '%s', 'delimiter', '\n')
string=validatestring('GlobalNormalization=',C)
v = sscanf(string,'%*s%f')
It works beautifully but matlab underlines "dataread" and tells me that it will be removed in future releases. Matlab suggests that i instead use tesxtscan. i threfore tried this - the code can be seen below
fid = fopen('test.dat','r');
C = textscan(fid, '%s','delimiter', '\n');
string=validatestring('GlobalNormalisation=',C);
v = sscanf(string,'%*s%f');
fclose(fid);
this gives me the error message:
"Error using validatestring (line 61) Second argument must be a cell array of allowed strings.
Error in Import_Int (line 9) string=validatestring('GlobalNormalisation=',C);"
I think the reason for this is that dataread simply creates a variable called C wheras textscan creates a 1x1 cell called C. Can anyone tell me how to simply create a variable called C using textscan or suggest some other way of working around the problem?
cheers