%% Function ootrix( M ) 
%%
%% By: Michael K. Pellegrino
%%
%% input: any KxN matrix
%% output: a string formatted for Open Office
%%         of the matrix
%%

function [ret] = ootrix ( M )
  format rat;
  [nrow,ncol]=size( M );
  x="";
  v=1;
  x = strcat( x, "left [ ~ matrix { " );
  for i=1:nrow
    for j=1:ncol
      v++;
      x= strcat( x, num2str(M(i,j)) );
      if(( j == ncol ) && ( i == nrow ))
	x=strcat( x, " } ~ right ]  ");
      else if(( j == ncol ) && ( i != nrow ))
	  x=strcat( x, " ## ");
	else if(( j != ncol ) && ( v !=(nrow*ncol+1) ))
	    x=strcat( x, " #  ");
	  endif
	endif
      endif
    endfor
  endfor
  ret=x;
endfunction
