matlabFunction on symbolic experssion and the Error using symengine

6 visualizaciones (últimos 30 días)
Hello
I have a mix double integral and partial differential expression and I want to solve it by symbolic math in matlab.
My code below written to solve the equation. But matlabFunction() does not work on it and gives me an error.
I would be appreciated if anybody could help me. I tried the numerical way to solve this expression but I could not find the right result. The only way that I think work is using symbolic math. Any idea and help is appreciated.
Here is my code:
syms t z
w=1.11;
T=1.2;
zita=0.5;
a=1;
b=1;
d=0;
%%
teta=exp(-((1-t/T)*(t/T))^(-w));
phi=int(teta)/int(teta,0,T);
Y1=[1;1]+[1;2]*phi;
Y2=[2;1]+[1;1]*phi;
eta0=Y1+(z-zita)*Y2;
F=[(1/a)*(diff(eta0(1,1),t)-eta0(2,1)*eta0(1,1)); ...
(1/b)*(diff(eta0(2,1),t)-d*eta0(2,1))];
int1=int(F,z)-int(F,z,0,zita);
etaAux=int(int1,z)-int(int1,z,0,zita);
eta=eta0+etaAux;
etaD=diff(eta,z);
fun=matlabFunction(etaD);
After running the code, I got this error:
Error using symengine
Unable to evaluate to Boolean.
Error in sym/matlabFunction>mup2mat (line 404)
res = mupadmex('symobj::generateMATLAB',r.s,ano,spa,0);
Error in sym/matlabFunction>mup2matcell (line 374)
r = mup2mat(c{1},true,sparseMat);
Error in sym/matlabFunction (line 188)
body = mup2matcell(funs, opts.Sparse);
Could you please help me with this issue?
etaD is 2by1 and matlabFunction() works on etaD(2,1) but does not work on etaD(1,1) and gives me the same error as above.
  1 comentario
Walter Roberson
Walter Roberson el 30 de Mzo. de 2020
It has something to do with the square of an integral. It doesn't matter if it is numerator or denominator but it does matter that it is squared

Iniciar sesión para comentar.

Respuesta aceptada

Walter Roberson
Walter Roberson el 30 de Mzo. de 2020
It appears to be a bug. I might look into the internal code when I am more awake, but that code is difficult to read and debug.
In the meantime, there is a workaround. It takes a bit of time to compute it, but it gets there.
The workaround is instead of
matlabFunction(etaD)
use
matlabFunction(rewrite(etaD, 'sincos'))
You will have to wait a bit for it to compute the rewrite()
Do not simplify() the results of the rewrite() or else you get back to code that has the problem
  4 comentarios
Walter Roberson
Walter Roberson el 30 de Mzo. de 2020
Editada: Walter Roberson el 30 de Mzo. de 2020
Yes, you can matlabFunction(vpa(etaD))
I will file a bug report with Mathworks.
Amin NZH
Amin NZH el 30 de Mzo. de 2020
IT WORKS!
Thank you so much for your help and time.
I appreciate your kind guidance.
Best regards

Iniciar sesión para comentar.

Más respuestas (0)

Productos


Versión

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by