from
Arbitrary files & MATLAB variables <-> data stream vector converter
by Hoi Wong
Encode any MATLAB data types into a numeric array, and vice versa
|
| stream2file(dataStream, outputFileName)
|
function stream2file(dataStream, outputFileName)
% This program converts the dataStream generated by file2stream()
% back into a single file
%
% Application: Transfer data between remote COM client and server directly
%
% Implication: You can transfer files around just by converting them into
% a stream of numbers.
%
% Future work: Add compression feature to facilliate fast data transfer
%
% Author: Hoi Wong (wonghoi.ee@gmail.com)
% Date: 01/24/2008
if( ~ischar(outputFileName) )
error('Input filename can only be a simple string');
end
FID = fopen(outputFileName, 'w');
if(FID == -1) error('File cannot be opened'); end
% Write data stream into to the specified file
try
fwrite(FID, dataStream);
catch
fclose(FID);
error('File can be opened, but cannot be written');
end
fclose(FID);
|
|
Contact us at files@mathworks.com