aboutsummaryrefslogtreecommitdiff
path: root/matlab/comms/save_variable.m
blob: 6bc45e612d4c8787fe813e8a715ba17bc4cc1147 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
function save_variable (var, format, filename)

% function save_variable (var, format, filename)
%
% Saves a variable var to filename using format,
% e.g., save_variable (x, '%d', 'input.dat');

[fid, message] = fopen(filename, 'w');
if fid == -1
	disp('File error. Message returned was:')
	disp(message)
	return
end
fprintf(fid, [format,'\n'], var);
fclose(fid);
return;