Friday, November 25, 2005

 

Plotting in Matlab without X-window

Matlab can be operated in non-GUI mode. To start matlab:
matlab -nodesktop -nojvm -nosplash
If you wish to plot graphs without using X or GUI, open a figure with visibility hidden, plot the graph and then print the figure to a file.
>> h = figure('Visible', 'off')
h =

     1
figure returns a handle to figure. Now issue the plot command.
plot(1:4,5:8)
The figure can now be saved using the print command.
print -f1 -dps 'filename.ps'
The syntax for the print command is
print -fhandle -ddevice.
In our case, the handle is 1 and device is post script file.

Update: As posted by anonymous, another option is to use
saveas(h,'file.png');

Comments:
Another option is,

figure(..);
plot(..);
saveas(1,'file.png');

 
Correction...

h=figure(..);
plot(..);
saveas(h,'file.png');

 
Post a Comment



<< Home

This page is powered by Blogger. Isn't yours?