ListAnimate[y2]
makes me think you expect Do
to be able to work like Table
and produce a list of results of each iteration. It cannot. Return
could return a single result the first time it is executed (a.k.a. "evaluated") in the Do
loop. For it to return a plot, the argument to Return
should be a plot. But the argument is not a plot in any of your examples.
Further, you place Return[..]
as an argument to Plot[]
, in a position where Plot[]
expects an option. I get error messages, which seem to be ignored in question.
If you want to make a list of output (plots or whatever), use Table
or Map
. They're the best ways. If you want to make Do[]
construct your list then try something like this:
resultList = {}; (* initialize *)
Do[ nextResult = ...; AppendTo[resultList, nextResult], {...}]
Or this:
resultLL = {}; (* initialize linked list *)
Do[ nextResult = ...; resultLL = {resultLL, nextResult}, {...}];
resultList = Flatten[resultLL]; (* does not work if nextResult is a List *)
The second, linked-list way is usually more efficient than AppendTo
.