I have created a function "horzcatna" (see attached). It does the same thing as horzcat, but the matrices need not have the same number of rows. To make up the difference, NA values are inserted into the empty elements.

I created this function to simplify saving data out to files for plotting in external programs (e.g. gnuplot). If there is interest, I can revise it to meet Octave standards (texinfo help) and place it in the appropriate octave-forge package, perhaps "general". I don't think something comparable exists in Matlab.

Regards,
Jonathan
%% horzcatna (matrix1,matrix2,...)
%%
%% Return the horizontal concatenation of the provided matrices.  For
%% matrices with different numbers of rows, NA values are inserted
%% into the empty elements.

%%  author:  Jonathan Stickel
%%  created:  11/14/08
%%  modified:  12/5/08


function retvar = horzcatna (varargin)

  m = 0;
  for i = 1:nargin
    [j(i),k(i)] = size(varargin{i});
    m = max(j(i),m);
  endfor
  retvar = [];
  for i = 1:nargin
    retvar = [ retvar, [varargin{i};NA(m-j(i),k(i))] ];
  endfor
  
endfunction
------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Octave-dev mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/octave-dev

Reply via email to