Reputation: 132
The figure take the wanted size (269*203) but the output image is so big. I want it to take the same figure size.
here's my code
data=importdata('C:/Users/Eden/Desktop/Acceleration/data.txt');
fig = figure(1);
set(fig, 'Units', 'pixels');
set(fig, 'Position', [0 0 269 203]);
x=data(:,2)
y=data(:,3)
p=plot(x,y)
set(p,'Color','red');
xlabel('Time(milliseconds)','FontSize',12,'FontWeight','bold','Color','b');
ylabel('Acceleration(g unit)','FontSize',12,'FontWeight','bold','Color','b')
saveas(fig,'C:/Users/Eden/Desktop/didi.jpg')
Upvotes: 0
Views: 55
Reputation: 36710
Replace the last line with:
%tell print to use size of the gui-window
set(fig, 'PaperPositionMode','auto')
%use print because saveas ignores previous line
print('-djpeg','-r100','didi.jpeg')
Upvotes: 1