Reputation: 11340
I'm new to matlab. I have files conatins list of string like:
ABCCD
HGAQ
VBSER
I need to read it into cell array of character strings
.
I tried this code:
fid2 = fopen('C:\matlab\data\myfile.txt');
tline = fgetl(fid2);
while ischar(tline)
disp(tline)
tline = fgetl(fid2);
end
fclose(fid2);
However, I didn't know how to convert the output to cell array of character strings
Upvotes: 0
Views: 40
Reputation: 112659
importdata
does that for you:
>> x = importdata('file.txt');
x =
'ABCCD'
'HGAQ'
'VBSER'
>> whos x
Name Size Bytes Class Attributes
x 3x1 364 cell
Upvotes: 2