MATLAB: How can I use parameter instead of equation in dsolve

dsolve

Hi
I want to solve an ordinary differential symbolic equation with dsolve. But I want to save my equation in a parameter and use this parameter in dsolve. My codes are coming below:
clear all
syms a x
l=a*x;
dsolve('Dx=l')
these codes don't work. What should I do?
Thanks a lot

Best Answer

Hi Frank,
you can try something like
clear all; syms a x; l=a*x; dsolve(['Dx= ' char(l)])
The point is that variables/parameters inside a string cannot be "evaluated". But as the example suggests you can use the command CHAR to convert a symbolic expression to a character string and use the brackets to concatenate strings appropriately.
Hope this helps and best regards,
-- Kai