help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Plotting and Animating in Octave (vs. Matlab)


From: Jeff
Subject: Re: Plotting and Animating in Octave (vs. Matlab)
Date: Tue, 16 Jul 2013 14:24:34 -0400

Thanks, Philip. I will look at your code later tonight.

I did forget to mention that I am using GNU Octave, version 3.4.3 on Gentoo Linux (but I will have to research MinGW to determine if I'm using that or not).


On Tue, Jul 16, 2013 at 1:37 PM, PhilipNienhuis <address@hidden> wrote:
Jeffrey wrote
> I'm trying to make some plots and animations in Octave on a non-graphical
> cluster. Is this even possible? With the first code, I can get a rough,
> text-based plot. Is that the best I can do? Is there a way to animate (my
> second code)? If not animate, can I at least create a movie?
>
> Here's what I'm starting with (from Matlab). First, a plain old plot:
>     try close(2); end
> getframe.m <http://octave.1599824.n4.nabble.com/file/n4655707/getframe.m>
>     figure(2); h=axes; hold on;
>     col=1;
>
>     plot(Hn_f(:,col),'b-');
>     if N/2 >= 4, plot(Hn_f(:,col+2),'r-'); end
>     if N/2 >= 6, plot(Hn_f(:,col+4),'g-'); end
>     if N/2 >= 8, plot(Hn_f(:,col+6),'k-'); end
>
>     axis tight;
>     strTitle = ['Energy per Mode over Time (%d Masses, Beta=%.2f, %s
> BC)'];
>     strTitle=sprintf(strTitle, N, beta, boundary);
>     title(strTitle,'fontweight','b','FontSize',12);
>     xlabel('Time','fontweight','b');
>     ylabel('Energy','fontweight','b');
>     legend('Mode 1','Mode 3','Mode 5','Mode 7');
>     legend('Location','North');
>     hold off;
>
> And an animation. I can get a few successive text-based plots from this
> one, but then it just stops executing. In Matlab, I create a movie
> uncommenting the lines related to structure "M". Can I at least create a
> movie in Octave?
> rnge=(round(max(max(abs(U)))*10)+1)/10;
> xs=[0, N+1, 0, N+1, -rnge, rnge];
> txt=sprintf('%dx%d Lattice, %s BC, beta=%.2f', N, N, boundary, beta);
> strXlbl='Mass No.';     % Also Ylabel.
> strZlbl='Displacement';
>
> clear M;
> figure(2);
> % M = struct('cdata', cell(1,T+1), 'colormap', cell(1,T+1));
>
> for tt=0:T
>     mesh(vertcat(zeros(1,N+2), horzcat(zeros(N,1), ...
>         reshape(U(tt+1,:),N,N), zeros(N,1)), zeros(1,N+2)));
>     axis(xs);
>     title(sprintf([txt ', t=%d (of %d)'],tt, T));
>     drawnow;
>
> %     M(tt+1)=getframe(h);
> end
> hold off;
> % txt=sprintf('N=%02dx%02d_Beta=%.2f.avi', N, N, beta)
> % tic; movie2avi(M, txt); toc;

The last Octave version (for Windows) that had a somewhat functional[1]
video package included was 3.4.3 for MinGW. A function getframe() is still
lacking so I clumsily used a getframe.m (attached) comprising plotting to
file, reading that using imread, clipping to even numbers (plus some more
apparently required polishing) and adding the result to the movie using
addframe().
It didn't look quite as sleek as movies from Matlab :-(
Yet I still have 3.4.3 for MinGW around, as I occasionaly need / want to
make movies.

The video package could use some attention...

Alternatively, you might write successive GIF files and use 3rd party tools
to combine them into an animated GIF.

Philip

[1] That it builds and has been included in some binaries doesn't imply that
it really works




--
View this message in context: http://octave.1599824.n4.nabble.com/Plotting-and-Animating-in-Octave-vs-Matlab-tp4655680p4655707.html
Sent from the Octave - General mailing list archive at Nabble.com.
_______________________________________________
Help-octave mailing list
address@hidden
https://mailman.cae.wisc.edu/listinfo/help-octave


reply via email to

[Prev in Thread] Current Thread [Next in Thread]