Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- xmax = 4;
- ConvolveAnim[f_, g_, c_, t_] :=
- Module[{\[Tau] = 1.5 xmax - 2.5 xmax t}, Show[
- Plot[f[x], {x, -xmax, xmax}, PlotRange -> {0, 3}, Axes -> None,
- ImageSize -> 300]
- ,
- Plot[g[x + \[Tau]], {x, -xmax, xmax}],
- Plot[c[x], {x, -xmax, -\[Tau]},
- PlotStyle -> Directive[Thick, Black]],
- RegionPlot[
- 0 <= y <= g[x + \[Tau]] f[x], {x, -xmax, xmax}, {y, 0, 3},
- PlotPoints -> 50, PlotStyle -> RGBColor[0.8, 0.6, 0.65]]
- ]];
- conv[1, x_] := f[x];
- conv[n_, x_] :=
- conv[n, x] = (Convolve[f[ttt], conv[n - 1, ttt], ttt, xt]) /. {xt ->
- x};
- convs = Table[conv[i, x], {i, 5}];
- convs = convs/(convs /. {x -> 0});
- anim[n_, t_] :=
- ConvolveAnim[(convs[[n]] /. {x -> #}) &,
- f, (convs[[n + 1]] /. {x -> #}) &, t];
- animall[t_] := anim[1 + Floor[t], t - Floor[t]];
- frames = Table[animall[t], {t, 0, 3.99, 0.0399}];
- Export["convolve.gif", frames];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement