Converting Matlab ode45 into C with complex output

I tried using the Matlab coder tool in order to export my ode solver to C (hoping that I might get a run-time boost).
Since I am solving a Schrodinger equation my output should be a complex vector.
When I'm running my regular Matlab code, everything works just fine, but when the coder tool runs the check of the mex file, it returns an error - "the output data must be real when enforcing non-negativity...".
I couldn't find a place where it is stated that the Matlab coder can only convert ode45 with real input/output.
If it's not obvious, I didn't request the output to be real. I also tried defining both the input and the output as complex, and it didn't help.
Any suggestions?

Respuestas (1)

Torsten
Torsten el 20 de Nov. de 2017

0 votos

"the output data must be real when enforcing non-negativity...".
But you seem to use the non-negativity option of ODE45 which doesn't make sense for complex output.
Best wishes
Torsten.

1 comentario

I understand it implies that... This is why I wrote "If it's not obvious, I didn't request the output to be real".
What I enter is:
options=odeset('RelTol',10^(-10),'AbsTol',10^(-10));
[~,Psi1_1]=ode45(@Ham_t,linspace(0,t_gate,1000),Psi_0,options);
Even if I don't insert 'options' it outputs the same error.
Besides, if the problem was with my initial programming, the script wouldn't run on Matlab. But I'm only getting this error when I'm trying convert it into C using the coder tool.
Cheers, Daniel

Iniciar sesión para comentar.

Preguntada:

el 20 de Nov. de 2017

Comentada:

el 20 de Nov. de 2017

Community Treasure Hunt

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

Start Hunting!

Translated by