Substatuting numbers in dsolve
1 次查看(过去 30 天)
显示 更早的评论
The following is a program to solve a second order differential equation using dsolve. I would like to be able to vary the parameters of the RLC circuit that the programs solves. How do I get this program to run?
clc clear all close syms R1 R2 C L Vc0 iL0 R1 = 10; R2 = 8; C = 1/8; L = 2; Vc0 = 1; iL0 = 0.5;
V = dsolve('D2x + (1/L*C)*(L/R2+R1*C)*Dx + (1/L*C)*((R1+R2)/R2)*x = 0','Dx(0) = iL0/C-Vc0/(C*R2)','x(0) = 1') Vf = subs(I,{R1,R2,C,L,Vc0,iL0},{10,8,1/8,2,1,0.5})
1 个评论
Andrei Bobrov
2011-8-22
syms R1 R2 C L Vc0 iL0
V = dsolve('D2x + (1/L*C)*(L/R2+R1*C)*Dx + (1/L*C)*((R1+R2)/R2)*x = 0','Dx(0) = iL0/C-Vc0/(C*R2)','x(0) = 1')
subs(V,{R1,R2,C,L,Vc0,iL0},{10,8,1/8,2,1,0.5})
回答(1 个)
Andrei Bobrov
2011-8-22
variant
syms R1 R2 C L Vc0 iL0
V = dsolve('D2x + (1/L*C)*(L/R2+R1*C)*Dx + (1/L*C)*((R1+R2)/R2)*x = 0','Dx(0) = iL0/C-Vc0/(C*R2)','x(0) = 1')
1.
Vw = vpa(subs(V,{R1,R2,C,L,Vc0,iL0},{10,8,1/8,2,1,0.5}),5);
2.
G = matlabFunction(V);
Vw = G(10,8,1/8,2,1,0.5,sym('t'))
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!