How to use an object property in a rogue function?

Hello, I want to define an object's property as an algebraic expression and use it as a private function in the integral method. This is how I tried:
syms x
r1 = reaction;
r1.rx=1./(k1*(1-x));
q1=integral(@(x)r1.rx,0,0.5)
However I get the following error:
Error using integralCalc/finalInputChecks (line 511)
Input function must return 'double' or 'single' values. Found 'sym'.
Everything works fine if I use the expression directly on the private function.

 Respuesta aceptada

madhan ravi
madhan ravi el 4 de Dic. de 2018
r1.rx=matlabFunction(1/(k1*(1-x))) %change this line and remove @(x) from the next line

2 comentarios

Thanks, works perfecly now :D
madhan ravi
madhan ravi el 4 de Dic. de 2018
Anytime :)

Iniciar sesión para comentar.

Más respuestas (0)

Preguntada:

el 4 de Dic. de 2018

Comentada:

el 4 de Dic. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by