I tried both Dsolve and NDsolve for the following differential equation, it failed: It contains piecewise function
Clear["Global`*"]
i[\[Alpha]_, t_, vs_, tmax_] :=
Piecewise[{{0, t < 0}, {\[Alpha] t , 0 < t < (vs/\[Alpha])}, {vs,
tmax > t > (vs/\[Alpha])}}]
Clear[\[Alpha], vs, vsmin, vsmax, \[Alpha]max, \[Alpha]min, \[Beta],
g, tmax, c, cres, tr];
Dsolve[{(vs - vc[t]) g ==
i[\[Alpha], t, vs, tmax] + (1 + g*cres)*c*vc'[t], vc[0] == vs} vc[
t], t]
Clear[\[Alpha], vs, vsmin, vsmax, \[Alpha]max, \[Alpha]min, \[Beta],
g, tmax, c, cres, tr];
tr = 30*10^-12
vs = 1;
\[Alpha] = vs/tr;
g = 1*10^3;
c = 6*10^-9;
\[Beta] = 5;
cres = 0.4;
tmax = \[Beta]*tr;
Plot[i[\[Alpha], t, vs, tamx], {t, 0, tmax}]
NDSolve[{(vs - vc[t]) g ==
i[\[Alpha], t, vs, tmax] + (1 + g*cres)*c*vc'[t],
vc[0] == vs}, vc, {t, 0, tmax}]
Plot[Evaluate[vc[t], {t, 0, tmax}], PlotRange -> All]
It keeps giving me the same input but reshaped
Would you please help?