Matlab routine for writing a vector in IJ format.

This commit is contained in:
falgout 2005-04-26 20:08:06 +00:00
parent 53a62d70c4
commit 655bbd3040

19
tools/writeijvec.m Normal file
View File

@ -0,0 +1,19 @@
function writeijvec(filename, x)
%-----------------------------------------------------------------------------
% writeijvec('filename', x):
% Writes to file 'filename' a vector x in IJ format.
%-----------------------------------------------------------------------------
fid=fopen(filename,'w');
nrows = size(x,1);
fprintf(fid,'%d %d\n', 0, nrows-1);
% the 'find' function does things in column order, so use A^T
i = (0:nrows-1)';
B(1,:) = i';
B(2,:) = x';
fprintf(fid,'%d %.10e\n', B);
fclose(fid);