How to assign values to the variables using "dsolve" for solving first order ODE Equations simultaneously ?
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I am using "dsolve" to solve my first order ode .The function "dsolve" works fine but it does not allow assigning values to the variables. My code is given as follows.
%Parameters clear all; syms A Epsilon0 k1 k2 e s d R s f T c0 ; A=0.5*10^(-9); Epsilon0=8.85*10^-12; k1=10; k2=10; e=1.6*10^-19; s = 1.8*10^(-9);%m gap size% d=3*s; % total distance R=1; t=0:(0.0001*10^-3):(0.5*10^-3); f=10000; v0=7.5; T=5/f; v=v0*sin(2*pi*f*t); plot(t,v); c0=(A*Epsilon0*k1)/d;
inits='q(0)=(20*10^(-20)),Q(0)=0'; [q,Q]=dsolve('Dq=((v/R)-(1/R)*(((d*q)+(s*Q))/(c0*d)))','DQ=(((q+Q)/(A*Epsilon0*k1))*s)',inits);
OUTPUT q =
(c0*d*exp((s*t)/(2*A*Epsilon0*k1)............................................(this is so long expression).
Issue: In the above out, the variables are used instead of the values i have assigned and initialized in the code .
Requirement : I need these variables to be replaced by the values i have assigned to them.
0 commentaires
Réponse acceptée
Mischa Kim
le 20 Avr 2015
AK, use the subs command. I also recommend differentiating between the symbolic variables and their numeric values, e.g. A versus An .
syms A Epsilon0 k1 k2 e s d R s f T c0
An = 0.5*10^(-9);
Epsilon0n = 8.85*10^-12;
k1n = 10;
k2n = 10;
en = 1.6*10^-19;
sn = 1.8*10^(-9);%m gap size%
dn = 3*s; % total distance
Rn = 1;
inits = 'q(0)=(20*10^(-20)),Q(0)=0';
[q,Q] = dsolve('Dq=((v/R)-(1/R)*(((d*q)+(s*Q))/(c0*d)))','DQ=(((q+Q)/(A*Epsilon0*k1))*s)',inits);
qn = vpa(subs(q,{A,Epsilon0,k1,k2,e,s,d,R},{An,Epsilon0n,k1n,k2n,en,sn,dn,Rn}),3);
1 commentaire
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Special Values 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!