Why is ySol(t) = Dsolve(ode,cond) wrong? What should it be instead?
4 views (last 30 days)
Show older comments
I solved the ODE by subsituting the the data in 'C' (numerous values) and i got a series of around 10 ODE eqs that look like this (heres one as an example):
ode(t) = diff(y(t), t)= 83136/832 - (100*y(t))/5
I want to solve for y(t) for all 10 eqs so i tried
ySol(t) = dsolve(ode,cond)
with the cond being
cond = y(0) == C
where C is workspace of 10 know values which i used to solve for the ode
this is the wrong part which i cant right
ySol(t) = dsolve(ode,cond)
any ideas on how i can solve the 10 odes for y(t)??
Warning: Number of equations greater than number of indeterminates. Trying heuristics to reduce
to square system.
> In symengine
In mupadengine/evalin_internal
In mupadengine/feval_internal
In dsolve>mupadDsolve (line 334)
In dsolve (line 203)
Error using mupadengine/feval_internal
Unable to reduce to square system because the number of equations differs from the number of
indeterminates.
Error in dsolve>mupadDsolve (line 334)
T = feval_internal(symengine,'symobj::dsolve',sys,x,options);
Error in dsolve (line 203)
sol = mupadDsolve(args, options);
0 Comments
Answers (2)
Torsten
on 1 Jan 2022
syms Cs t y(t)
ode = diff(y,t) == 40*Cs-40/280*y;
cond = y(0) == Cs;
ySol(t) = dsolve(ode,cond);
ysol_num = subst(ySol,Cs,C)
3 Comments
Torsten
on 1 Jan 2022
We understood this.
You will first have to solve one ODE with a symbolic variable for C (here Cs).
Then you can substitute your 10 values for C into the solution to obtain 10 solutions.
Paul
on 1 Jan 2022
I think the ode needs to be solved first, and then sub in the values of y(0) to get the family of solutions (if I understand the question)
syms y(t) C
ode = diff(y,t) == 40*C-40/280*y;
ysol(t) = dsolve(ode)
Now solve for the constant C1 by enforcing the initial condition
syms C1
C1 = solve(ysol(0) == C,C1)
Now sub back into the solution
ysol(t) = subs(ysol(t))
Now sub in some values of C for specific initial conditions
y(t) = subs(ysol(t),C,[1 2])
3 Comments
Paul
on 1 Jan 2022
As far as I know, if you want to solve 10 odes using one call to dsolve, you'll need to have 10 functions to solve for, like y1(t), y2(t), etc.
Or, you can solve the equation once with C as a parameter, and then sub in the 10 values of C to get the 10 solutions, as both I and @Torsten, have shown. Is there a reason this approach is not acceptable?
I suppose another option is to define the 10 odes a priori and then loop through dsolve to solve each, like this:
C = [1 2];
syms y(t)
odes = diff(y(t),t) == 40*C-40/280*y;
odes = odes(t);
for ii = 1:numel(C)
ysol(ii) = dsolve(odes(ii),y(0)==C(ii));
end
ysol
which yields the same result shown above.
See Also
Categories
Find more on Equation Solving in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!