Trying to make my graphs in a Do loop, just to familiarize myself with another way to do this. I've read that when Return is used with Do, then Do sometimes doesn't give Null. I looked up Return, and they use Return[a], on the examples in the documentation. I tried that; I also tried Return[y2] and Return[y[x,t]], besides experimenting with the placement of the Return command, within the Do loop. Here is one of my attempts. Why am I not getting output?
ClearAll[y,x,t]
h=1;l=10;v=1;
y[x_,t_]=Sum[(8h/(n^2 Pi^2))(2 Sin[n Pi/4]-Sin[n Pi/2]) Sin[ n Pi x/l] Cos[n Pi v*t/l], {n,140,1}];
y2=Do[Plot[y[x,t],{x,0,10}, AxesLabel->{"x","y[x,t]"}, PlotLegends->StringJoin["t=",ToString[t]],Return[a]],{t,0,2l/v,.02l/v}];
ListAnimate[y2]
Another attempt was,
ClearAll[y,x,t]
h=1;l=10;v=1;
y[x_,t_]=Sum[(8h/(n^2 Pi^2))(2 Sin[n Pi/4]-Sin[n Pi/2]) Sin[ n Pi x/l] Cos[n Pi v*t/l], {n,140,1}];
y2=Do[Plot[y[x,t],{x,0,10}, AxesLabel->{"x","y[x,t]"}, PlotLegends->StringJoin["t=",ToString[t]],Return[y[x,t]],{t,0,2l/v,.02l/v}];
ListAnimate[y2]
I also tried,
ClearAll[y,x,t]
h=1;l=10;v=1;
y[x_,t_]=Sum[(8h/(n^2 Pi^2))(2 Sin[n Pi/4]-Sin[n Pi/2]) Sin[ n Pi x/l] Cos[n Pi v*t/l], {n,140,1}];
y2=Do[Plot[y[x,t],{x,0,10}, AxesLabel->{"x","y[x,t]"}, PlotLegends->StringJoin["t=",ToString[t]],{t,0,2l/v,.02l/v}, Return[y2]];
ListAnimate[y2]
Would love any input on how I can actually get figures while using a Do loop. Thanks so much