Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to read lines into cell array at the matlab

Tags:

file-io

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}
like image 896
MonsterMMORPG Avatar asked Dec 05 '22 14:12

MonsterMMORPG


1 Answers

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
like image 200
Jonas Avatar answered Jan 18 '23 03:01

Jonas