Matlab routine for writing a vector in IJ format.
This commit is contained in:
parent
53a62d70c4
commit
655bbd3040
19
tools/writeijvec.m
Normal file
19
tools/writeijvec.m
Normal 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);
|
||||||
Loading…
Reference in New Issue
Block a user