how to write and read file quickly?

1 view (last 30 days)
Rohit Bhoi
Rohit Bhoi on 8 Mar 2016
Edited: Stephen23 on 8 Mar 2016
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?

Answers (1)

Walter Roberson
Walter Roberson on 8 Mar 2016
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!