How can I input variables to dsolve?

3 vues (au cours des 30 derniers jours)
April
April le 23 Fév 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!

Réponses (1)

Walter Roberson
Walter Roberson le 23 Fév 2013
subs(Q, 'A', A)

Catégories

En savoir plus sur Get Started with MATLAB dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by