I have a problem with MATLAB that i cant quite fix. It is throwing me an error, stating
??? Error using ==> fprintf
Function is not defined for 'cell' inputs.
Error in ==> writedata at 93
fprintf(fout, 'INSERT INTO postgres VALUES( %s, %s, %s.\n )', domain, start, stop);
@Florian Brucker wrote me this code and i changed the code to run 2 regular expressions instead of one, since the one regular expression seems to copy over both of the strings in the document into one cell array when its supposed to be in two separate cell arrays.
domain = '';
start = '';
stop = '';
fin = fopen('CathDomainDescriptionFile.txt', 'r');
fout = fopen('output_cath.txt', 'w');
% TODO: Add error check!
while true
line = fgetl(fin); % Get the next line from the file
if ~ischar(line)
% End of file
break;
end
[key, value] = strtok(line); % Split line at the first space
switch key
case 'DOMAIN'
% Store domain
domain = value;
case 'SRANGE'
% two regular expressions since the doing it all in one throws an error
% Index exceeds matrix dimensions.
m = regexp(value, 'START=(\d+)', 'tokens');
m2 = regexp(value, 'STOP=(\d+)', 'tokens');
start = m;
stop = m2;
% Print result
fprintf(fout, 'INSERT INTO postgres VALUES( %s, %s, %s.\n )', domain, start, stop);
end
end
fclose(fin);
fclose(fout);
It seems to print out the results for the DOMAIN, but not for the START and STOP values, due to the error. It should just simply, print out the Domain number, START and STOP values inside of the fprintf statement.
I am a beginner to MATLAB.