在Matlab中导出具有自定义大小的数字

时间:2015-03-28 09:41:07

标签: matlab plot figure

该图采用所需尺寸(269 * 203),但输出图像非常大。我希望它采用相同的数字大小。

这是我的代码

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')

1 个答案:

答案 0 :(得分:1)

将最后一行替换为:

%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')