%% variables samples = 262e+3; filename = 'O_262Kpts.WFM'; %% create test waveform wave = -2.*rand(samples, 1)+1; sample_bytes = num2str(samples*5); length_bytes = num2str(length(sample_bytes)); header = ['#' length_bytes sample_bytes]; %% file operations crlf = hex2dec({'0d' '0a'}); fid = fopen(filename, 'w'); fwrite(fid, 'MAGIC 1000'); fwrite(fid, crlf); fwrite(fid, header); fwrite(fid, wave(1), 'float'); fwrite(fid, wave(2:end), 'float', 1); % skip marker bytes fwrite(fid, 'CLOCK 1.10e+08'); fwrite(fid, crlf); fclose(fid);