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.

 Accepted Answer

r1.rx=matlabFunction(1/(k1*(1-x))) %change this line and remove @(x) from the next line

More Answers (0)

Community Treasure Hunt

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

Start Hunting!