MATLAB: Read 1 column .txt file into 1byn matrix

text to matrix

Hello,
I am trying to read file text.txt that looks like this
F1:3B
F2:22
F3:34
and save it in a matrix M, where M(1)=F1:3B etc

Best Answer

fid = fopen('text.txt','rt');
M = textscan(fid,'%s');
fclose(fid)
M = M{1};
Then M will contain a column vector cell array with those strings in it. You can access the strings using cell array indexing, e.g. the second row/string:
M{2}