Animating and Saving a Movie of a Function with “ListAnimate”

ClearAll["Global`*"];

f[x_,k_]=Sin [k x]; (* the basic function being plotted *)
(* "f" is a function of "x", but "k" is the frequency value that distinguishes each frame from the others *)
xmin=0;xmax=10;ymin=-1;ymax=1; (* plot limits *)
kmin = 0.1; kmax=2.0;kstep=0.1 ;(* k is the "time" dependent parameter. *)
picturestack=Table[Plot[f[x,k],{x,xmin,xmax},PlotRange->{ymin,ymax}],{k,kmin,kmax,kstep}];
(* So here, "picturestack" is a "Table" , which is Mathematica-speak for an array. In this case, it happens to be an array of plots, and a plot is more or less the same thing as an image. *)
setofframes=ListAnimate[picturestack] (* this line is just here so you can view the "movie" here in Mathematica *)

path = "C:\\Users\\pogo\\Desktop\\MMA\\anim1.gif";
(* You'll obviously need to put in a path that's appropriate to your own computer!! *)
(* Note: I don't know about Macs, which might need forward slashes, but this PC path & folder structure requires double-backslashes where normally only a single backslash is required *)
(* The resulting file is an "animated gif". I can't view it in my "windows photo viewer" (it only shows the first frame). However, I can drag it into PowerPoint or Firefox to watch the animated result. *)

Export[path,setofframes];