I've realized that, in the simple function I'm trying to write, textscan appears to be reading in the text and surrounding it with single quotes. Here's what I mean:
Test file contents: ABCCBDXYZABCZZ
MATLAB commands:
fileID=fopen(FILENAME); str=textscan(fileID,'%s');
The result of this is a 1×1 cell, as expected, however the contents of the cell are: 'ABCCBDXYZABCZZ' instead of ABCCBDXYZABCZZ
This is proving to be an issue because accessing the cell contennts with "string = str{1}" only returns a cell, instead of an actual string- so I can't do any string operations on it. Is this intended behavior?
When I manually create a cell with the following:
cell_test = {'ABCDEF'};
the workspace shows the variable is a 1×1 cell, but the contents of the cell are ABCDEF without the single quotes, so if I do
string_test = cell_test{1}
it sets the actual string to that variable, instead of the string surrounded by single quotes, which is treated as another cell.
I can't find this issue anywhere else- it's possible that I've looked in the wrong place, but all the results are about not accessing the cell contents properly, which I don't believe I'm suffering from.
Best Answer