Using dsolve, replace arbitrary constants like C11 with one's own parameter name.
Mostrar comentarios más antiguos
when one solves a differential equation using dsolve, without specifying terminal conditions, matlab outputs the solution with an arbitrary parameter name. Here's an example.
syms c T lambda0 x(tau) x0 xT a tau
xDot = @(tau) a*x - exp(-a*tau)/lambda0;
diffEqSolve = dsolve(diff(x,1) == xDot(tau));
diffEqSolve is now:
C3*exp(a*tau) + exp(-a*tau)/(2*a*lambda0)
Since I known that the solution to this problem will have just one parameter, I'd like to pass my own symbol to dsolve. E.g., pass the symbolic variable 'c' to dsolve, and have it return
c*exp(a*tau) + exp(-a*tau)/(2*a*lambda0)
If this isn't possible (I suspect it isn't), could somebody please explain how matlab decides what number to append to C? I've had the same string of commands return C3 or C11, depending on what commands have be processed before dsolve is invoked, and have been unable to see any pattern. If I could compute the number beforehand, then I could do a subs command and get the result I want, e.g.,
diffEqSolve = subs(dsolve(diff(x,1) == xDot(tau)),'C3','c')
Thanks in advance for any suggestions.
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Calculus en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!