help-octave
[Top][All Lists]
Advanced

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

Plotting and Animating in Octave (vs. Matlab)


From: Jeff
Subject: Plotting and Animating in Octave (vs. Matlab)
Date: Mon, 15 Jul 2013 21:15:47 -0400

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
    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;

Thanks for your help.

reply via email to

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