How to simply this script to create figures?
Afficher commentaires plus anciens
I prepared the following script to create two figures. Each figure has 2-by-6 subplots. The only difference between them is that the first one uses a plot function and the second one uses a semilogy function. Otherwise, legend, xlabel, ylabel, and position are the same. Also, I want to export the figures as Fig1.eps and Fig2.eps files. How can I further simply this script to avoid repeated codes?
harray(1)=figure('Name',fname{1});
for k1 = 1:12
h{k1} = subplot(2,6,k1)
hLine{k1} = plot(X,Y(k1,:),X,Z(k1,:));title(type{k1});
end
legend('test1','test2');
xlabel(h{7},'\fontname{Helvetica}X');
xlabel(h{8},'\fontname{Helvetica}X');
xlabel(h{9},'\fontname{Helvetica}X');
xlabel(h{10},'\fontname{Helvetica}X');
xlabel(h{11},'\fontname{Helvetica}X');
xlabel(h{12},'\fontname{Helvetica}X');
ylabel(h{1},'\fontname{Helvetica}Y');
ylabel(h{7},'\fontname{Helvetica}Y');
set(harray(1), 'Position', [0 0 1366 768]);
print -depsc Fig1
harray(2)=figure('Name',fname{2});
for k1 = 1:12
h{k1} = subplot(2,6,k1)
hLine{k1} = semilogy(X,Y(k1,:),X,Z(k1,:));title(type{k1});
end
legend('test1','test2');
xlabel(h{7},'\fontname{Helvetica}X');
xlabel(h{8},'\fontname{Helvetica}X');
xlabel(h{9},'\fontname{Helvetica}X');
xlabel(h{10},'\fontname{Helvetica}X');
xlabel(h{11},'\fontname{Helvetica}X');
xlabel(h{12},'\fontname{Helvetica}X');
ylabel(h{1},'\fontname{Helvetica}Y');
ylabel(h{7},'\fontname{Helvetica}Y');
set(harray(2), 'Position', [0 0 1366 768]);
print -depsc Fig2
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Creating, Deleting, and Querying Graphics Objects dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!