到目前为止,我已经查找了关于在Matlab中打印图形的这个简单问题。我有一个这种类型的for循环:
N = 5;
for sim = 1:10
X = randn(sim,N);
X = mean(X);
figure;
plot(X);
print -depsc X;
end
我想为每个模拟打印并保存一个新图形,并自动命名,例如,X1表示sim = 1,X2表示sim = 2,X3表示sim = 3,等等。我该怎么做?
答案 0 :(得分:1)
试试这个:
N = 5;
for sim = 1:10
X = randn(sim,N);
X = mean(X);
hFig = figure;
plot(X);
% create filename and print to eps
filename = strcat('X',num2str(sim));
print(hFig,filename,'-depsc');
end
希望这有帮助!