How to apply functions to symmatrix objects, in the same way as to sym objects.
Hi
I work with symbolic matrix objects, defined as symmatrix.
Unfortunatly, symmatrix is not compatible with as many functions as a symbolic scalar (sym). In my case i would like to apply normcdf or equivalently erf to a symmatrix matrix (as an elementwise operation, like it could be done with a double matrix). This cant be done.
% works for scalars
syms y x;
a=erf(y*x);
b=normcdf(y*x);
diff(a,x)
diff(b,x)
% fails for symmatrix
Y = symmatrix(‘Y’,[2,1]);
syms x
a=erf(Y*x)
b=normcdf(Y*x)
diff(a,x)
diff(b,x)
I am wondering if there is a workaround via an abstract function. I thought maybe symfunmatrix helps, but I couldnt get it to do what I want.
Importantly, I dont want any conversion to sym, because I want to later use the resulting matrix expressions for numeric evaluation for arbitrary n. Conversion to sym would turn matrix expressions into element by element operatons and make the numeric evaluation slow.Hi
I work with symbolic matrix objects, defined as symmatrix.
Unfortunatly, symmatrix is not compatible with as many functions as a symbolic scalar (sym). In my case i would like to apply normcdf or equivalently erf to a symmatrix matrix (as an elementwise operation, like it could be done with a double matrix). This cant be done.
% works for scalars
syms y x;
a=erf(y*x);
b=normcdf(y*x);
diff(a,x)
diff(b,x)
% fails for symmatrix
Y = symmatrix(‘Y’,[2,1]);
syms x
a=erf(Y*x)
b=normcdf(Y*x)
diff(a,x)
diff(b,x)
I am wondering if there is a workaround via an abstract function. I thought maybe symfunmatrix helps, but I couldnt get it to do what I want.
Importantly, I dont want any conversion to sym, because I want to later use the resulting matrix expressions for numeric evaluation for arbitrary n. Conversion to sym would turn matrix expressions into element by element operatons and make the numeric evaluation slow. Hi
I work with symbolic matrix objects, defined as symmatrix.
Unfortunatly, symmatrix is not compatible with as many functions as a symbolic scalar (sym). In my case i would like to apply normcdf or equivalently erf to a symmatrix matrix (as an elementwise operation, like it could be done with a double matrix). This cant be done.
% works for scalars
syms y x;
a=erf(y*x);
b=normcdf(y*x);
diff(a,x)
diff(b,x)
% fails for symmatrix
Y = symmatrix(‘Y’,[2,1]);
syms x
a=erf(Y*x)
b=normcdf(Y*x)
diff(a,x)
diff(b,x)
I am wondering if there is a workaround via an abstract function. I thought maybe symfunmatrix helps, but I couldnt get it to do what I want.
Importantly, I dont want any conversion to sym, because I want to later use the resulting matrix expressions for numeric evaluation for arbitrary n. Conversion to sym would turn matrix expressions into element by element operatons and make the numeric evaluation slow. symmatrix, symbolic math toolbox MATLAB Answers — New Questions