Hello,
I created an object that accepts a formula (i.e. Tranfunction ='a.*b.*c') and a matrix of values ( i.e. Mat = [ 1 2 3; 4 5 6; 7 8 9] ). Once these variable and Matrix have been loaded into the object the following code is applied.
fun = inline(obj.TranFunction);
NewMatrix = fun(Mat(:,1), Mat(:,2), Mat(:,3));
This works great.
However, the Tranfunction can be enter as anything (i.e. tranfunction = '(12.*e.*d.*c)./ ((4.*a.^3)-(3.*b.*(2.*pi.*a.^2+pi.*b.^2+8.*a.*b)) + (12.*(a+b).^2))' and the corresponding matrix( i.e. Mat = [ 1 2 3 4 5; 4 5 6 6 7; 7 8 9 9 9] )
When this happens I have to change my code to:
fun = inline(obj.TranFunction);
NewMatrix = fun(Mat(:,1), Mat(:,2), Mat(:,3), Mat(:,4), Mat(:,5));
Is there a way that I can make the NewMatrix line of code dynamic? A piece of code that wouldn't require me to change the NewMatrix line every time the forumla changes?
Thanks for your help,
Jeff