Home > cellorganizer > utilities > matrix.m

matrix

PURPOSE ^

MATRIX Helper function that handles the reading of MathML matrices in

SYNOPSIS ^

function array = matrix( mathml )

DESCRIPTION ^

MATRIX Helper function that handles the reading of MathML matrices in
presentation format.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function array = matrix( mathml )
0002 %MATRIX Helper function that handles the reading of MathML matrices in
0003 %presentation format.
0004 
0005 % Author: Ivan E. Cao-Berg (icaoberg@cmu.edu)
0006 % Created: May 8, 2007
0007 % Last Update: March 4, 2008
0008 %
0009 % Copyright (C) 2008 Center for Bioimage Informatics/Murphy Lab
0010 % Carnegie Mellon University
0011 %
0012 % This program is free software; you can redistribute it and/or modify
0013 % it under the terms of the GNU General Public License as published
0014 % by the Free Software Foundation; either version 2 of the License,
0015 % or (at your option) any later version.
0016 %
0017 % This program is distributed in the hope that it will be useful, but
0018 % WITHOUT ANY WARRANTY; without even the implied warranty of
0019 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0020 % General Public License for more details.
0021 %
0022 % You should have received a copy of the GNU General Public License
0023 % along with this program; if not, write to the Free Software
0024 % Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
0025 % 02110-1301, USA.
0026 %
0027 % For additional information visit http://murphylab.web.cmu.edu or
0028 % send email to murphy@cmu.edu
0029 
0030 noRows = 0;
0031 noColumns = 0;
0032 
0033 % Calculate the number of rows
0034 for i=2:1:length(mathml)-1
0035     if( findstr( mathml{i}, 'arrayrow' ) )
0036         noRows = noRows + 1;
0037     end
0038 end
0039 noRows = noRows/2;
0040 
0041 % Calculate the number of columns
0042 for i=2:1:length(mathml)-1
0043     if( findstr( mathml{i}, 'cn' ) )
0044         noColumns = noColumns + 1;
0045     end
0046 end
0047 noColumns = noColumns / noRows;
0048 
0049 % Create an empty matrix of fixed size
0050 array = zeros( noRows, noColumns );
0051 
0052 % Fill the empty matrix
0053 temp = [];
0054 for i=2:1:length(mathml)-1
0055     if( findstr( mathml{i}, 'cn' ));
0056         delimiter = findstr( mathml{i}, '<' );
0057         temp = [temp, str2double(mathml{i}(5:delimiter(2)-1))];
0058     end
0059 end
0060 
0061 counter = 1;
0062 for i=1:1:noRows
0063     for j=1:1:noColumns
0064         array(i,j)=temp(counter);
0065         counter = counter + 1;
0066     end
0067 end
0068 end%matrix

Generated on Sun 29-Sep-2013 18:44:06 by m2html © 2005