www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/AppendDataToBinaryFileExample.m
%% Append Data to Binary File % Write a binary file containing the elements of the 4-by-4 magic square, % stored as double-precision floating-point numbers. % Copyright 2015 The MathWorks, Inc. fileID = fopen('magic4.bin','w'); fwrite(fileID,magic(4),'double'); fclose(fileID); %% % Open the file, |magic4.bin|, with write-access that enables appending to % the file. Specify the file-access type, |'a'|, in the call to |fopen|. fileID = fopen('magic4.bin','a'); %% % Append a 4-by-4 matrix of zeros to the file. Then, close the file. fwrite(fileID,zeros(4),'double'); fclose(fileID);