How to find value of symfun x at time y?

10 views (last 30 days)
I am solving a system of differential equations. So far so good:
syms i1(t) v1(t)
eqn1 = diff(i1) == VS/L - v1/L;
eqn2 = diff(v1) == i1/C1 - IX/C1;
c1 = i1(0) == IL0;
c2 = v1(0) == 0;
[i1_sol(t) v1_sol(t)] = dsolve(eqn1,eqn2,c1,c2)
Now, I need to know the value of i1(t) and v1(t) at time ta to serve as initial conditions for my next set of diff eqs.
I have tried double and vpa to no avail. How can I extract these values?
Here's the output I'm getting with what I've tried:
>> v1(ta)
ans =
v1(1770887431076117/295147905179352825856)
>> double(v1(ta))
Error using symengine
DOUBLE cannot convert the input expression into a double array.
If the input expression contains a symbolic variable, use VPA.
Error in sym/double (line 588)
Xstr = mupadmex('symobj::double', S.s, 0);
>> vpa(v1(ta))
ans =
v1(1770887431076117/295147905179352825856)
>>
Note, 1770887431076117/295147905179352825856 is simply the value of ta.

Accepted Answer

LShaver
LShaver on 18 Dec 2015
Rookie mistake. Was using v1 (input function) when I should have been using v1_sol, the solution to the system:
>> double(v1_sol(ta))
ans =
96.9720

More Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!