Friday, November 25, 2005
Plotting in Matlab without X-window
Matlab can be operated in non-GUI mode. To start matlab:
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
matlab -nodesktop -nojvm -nosplashIf 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 = 1figure 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');