How can I input variables to dsolve?

3 views (last 30 days)
April
April on 23 Feb 2013
I'm writing a function using dsolve, and earlier in the function I request input from the user at the keyboard, and save this input to the variable "A". When using dsolve, I cite the variable "A", but dsolve's solution leaves in the letter A instead of replacing it with the numerical answer the user provides. How can I fix this? Below is my code. I've tried using syms but I'm not sure how to make it work.
A=input('Enter the initial amount of the parent:');
Q=dsolve('DQ=(-1)*L*Q','Q(0)=A','t')
%The output is: Q = A/exp(L*t)
%I want A to take on the value that the user enters at the keyboard (for example, 7). Please help!

Answers (1)

Walter Roberson
Walter Roberson on 23 Feb 2013
subs(Q, 'A', A)

Categories

Find more on Get Started with MATLAB in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!