MATLAB: To read a text file using matlab

text filetext;textread

hi, this is a simple question
v='C:\Users\punith\Desktop\1.txt';% path
how to read text file using v

Best Answer

Use fopen to open the file and then use fscanf or fgetl to read in the content. You can also use fread. For example, the following code reads the first line of the text.
fid = fopen(v,'r');
tline = fgetl(fid);
fclose(fid)
Just to remember close the file using fclose afterwards.
doc fopen
doc fclose
doc fread
doc fscanf
doc fgetl