Home > source > generateCoefficientEquationFromString.m

generateCoefficientEquationFromString

PURPOSE ^

Take the coefficients of variables that don't have, for construction, any divisor then build an eqation with them.

SYNOPSIS ^

function [ theCoefficient ] = generateCoefficientEquationFromString( chr )

DESCRIPTION ^

Take the coefficients of variables that don't have, for construction, any divisor then build an eqation with them.

Prototype: [theCoefficient] = generateCoefficientEquationFromString(chr)

Input:  chr - Char equation.

Output: theCoefficient - String of coefficient.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 %Take the coefficients of variables that don't have, for construction, any divisor then build an eqation with them.
0002 %
0003 %Prototype: [theCoefficient] = generateCoefficientEquationFromString(chr)
0004 %
0005 %Input:  chr - Char equation.
0006 %
0007 %Output: theCoefficient - String of coefficient.
0008 
0009 function [ theCoefficient ] = generateCoefficientEquationFromString( chr )
0010 
0011 chr = strrep(chr,'+ ','+');
0012 chr = strrep(chr,'- ','-');
0013 pieces = strsplit(' ',chr);
0014 
0015 i = 1;
0016 index = 1;
0017 coefficient = pieces(1);
0018 found = false;
0019 while i <= length(pieces)
0020     actualPiece = pieces(i);
0021     if cellfun(@isempty,strfind(actualPiece,'/'))==true
0022         coefficient(index) = actualPiece;
0023         index = index+1;
0024         found = true;
0025     end
0026     i = i + 1;
0027 end
0028 
0029 if found == true
0030     theCoefficient = char(coefficient(1));
0031     match = 2;
0032     while match <= length(coefficient)
0033         theCoefficient = strcat(theCoefficient,char(coefficient(match)));
0034         match = match + 1;
0035     end
0036 else
0037     theCoefficient = 0;
0038 end
0039 
0040 return;
0041 
0042 end

Generated on Thu 24-Sep-2009 17:17:32 by m2html © 2005