开发者

What's the simplest way to read data from a text file into a 1xN integer in MatLab

What's the simplest way to read datas from a text file into a 1xN integer in MatLab?

I'm writing the data into a text file from a Java program, which means it is highly flexible how 开发者_运维技巧the text file could look like. These data are to be plotted (pdf or cdf).

The file could be quite large, millions of integers. It shouldn't matter I guess.


If it's a text file (not a binary file), you can probably just use the LOAD command:

data = load('file.txt','-ascii');  %# Load the data
data = data(:).';                 %'# Format the data into a row vector

I assume your data file could have one value per row or one long row with values separated by spaces, so the (:).' operation (a colon reshape plus a transpose) ensures that no matter which one it is you will get a 1-by-N result for data.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜