flirtmat_write | |
Type: Class |
Category: Math Functions |
License: GNU General Public License |
Language: MATLAB |
Description: save a 4-by-4 matrix to a file as handled by flirt -init Example: flirtmat_write(fname, affinemat) |
Versions Of This Snippet::
|
Download a raw-text version of this code by clicking on "Download Version"
Latest Snippet Version: :0.9
function flirtmat_write(fname, mat)
%flirtmat_write: save a 4-by-4 matrix to a file as handled by flirt -init
% Example:
% flirtmat_write(fname, affinemat)
% See also: flirtmat_read, flirtmat2worldmat, worldmat2flirtmat
% Copyright 2009 Ged Ridgway <ged.ridgway gmail.com>
fid = fopen(fname, 'w');
% Note that transpose is needed to go from MATLAB's column-major matrix to
% writing the file in a row-major way (see also flirtmat_read)
str = sprintf('%f %f %f %f\n', mat');
fprintf(fid, str(1:end-1)); % drop final newline
fclose(fid);
Submit a new version
You can submit a new version of this snippet if you have modified it and you feel it is appropriate to share with others..