Furkan Gözükara
Furkan Gözükara

Reputation: 23860

How to read lines into cell array at the matlab

I want to read a regular text file into cell array at the matlab. How can i do that ?

I don't want any formatting. Reading as literals.

Thank you.

It will be row based array like 100x1

example of reading : dd = {1;2;3}

Upvotes: 4

Views: 12820

Answers (1)

Jonas
Jonas

Reputation: 74940

Use textscan, so to have one cell element per line:

fid = fopen('myFile.ext');
allData = textscan(fid,'%s','Delimiter','\n');

% allData{1} is a nLines-by-1 cell array with the lines of the file as text

Upvotes: 16

Related Questions