# Matlab: differential equation: starting conditions are wrong?

2 views (last 30 days)
Niklas Kurz on 9 May 2021
Commented: Niklas Kurz on 12 May 2021
I solved manually: with  but if I solve it with Matlab:
syms v(t) g alpha m v0;
D = diff(v,t) == g - alpha/m*v;
c1 = v;
cond = c1(0) == v0;
S = dsolve(D,cond);
pretty(S)
I get a different solution, even if I'm sure mine is right.
I know this topic is a little vast, but maybe some of you talented people has time to investigate

Cris LaPierre on 9 May 2021
Edited: Cris LaPierre on 9 May 2021
I'm no expert, but isn't the integral equal to That way, the algebra works out to match the result MATLAB is giving you
syms v(t) g alpha m v0;
D = diff(v,t) == g - alpha/m*v;
cond = v(0) == v0;
S = dsolve(D,cond)
S = which simplifies to ##### 1 CommentShowHide None
Cris LaPierre on 9 May 2021
Here's more details on the derivation ### More Answers (1)

Walter Roberson on 9 May 2021
syms v(t) g alpha m v0;
D = diff(v,t) == g - alpha/m*v;
c1 = v;
cond = c1(0) == v0;
S = dsolve(D,cond);
sum(cellfun(@(X) collect(X,[g,m,alpha]), children((collect(expand(S),g)))))
ans = ##### 1 CommentShowHide None
Niklas Kurz on 12 May 2021
as always you're the master of formatation