how to write and read file quickly?

조회 수: 1 (최근 30일)
Rohit Bhoi
Rohit Bhoi 2016년 3월 8일
편집: Stephen23 2016년 3월 8일
I have one data translation device of which I am getting data using 'getdata' function. now I have to save this data and once it saved I have to read it again and plot a graph.
I am getting data using following code
[d,t]=getdata(ai); // where d is data and t is time
data1=d(:,1);
data2=d(:,2);
I have to save this data very quickly and again read it and plot graph.
which method shall I use?? xslread and write or csvread and write or dlmread and write?

답변 (1개)

Walter Roberson
Walter Roberson 2016년 3월 8일
fwrite() the data to the file, and fread() it from the file.
When you are reading from the device, depending on what it is, you might be able to use memmap
Separately from that, when you are dealing with the file I/O in MATLAB, you might be able to use memmapfile(). An example of using that to communicate between sessions is http://www.mathworks.com/help/matlab/import_export/share-memory-between-applications.html
If you have two different MATLAB sessions that are using a file to communicate, you should consider instead using a shared memory segment; see http://www.mathworks.com/matlabcentral/fileexchange/28572-sharedmatrix

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by