How can I input variables to dsolve?

3 visualizaciones (últimos 30 días)
April
April el 23 de Feb. de 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!

Respuestas (1)

Walter Roberson
Walter Roberson el 23 de Feb. de 2013
subs(Q, 'A', A)

Categorías

Más información sobre Get Started with MATLAB en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by