2017-05-10 1 views
0

J'ai jusqu'ici recherché cette question simple concernant l'impression de graphes dans Matlab. J'ai une boucle de ce type:Comment utiliser la commande d'impression avec des boucles dans Matlab

N = 5; 
for sim = 1:10 
    X = randn(sim,N); 
    X = mean(X); 

    figure; 
    plot(X); 
    print -depsc X; 
end 

Je voudrais imprimer et enregistrer un nouveau graphique pour chaque simulation, et nommez automatiquement, par exemple, X1 pour sim = 1, X2 pour sim = 2, X3 pour sim = 3, etc. Comment faire ceci?

Répondre

1

Essayez ceci:

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 

Hope this helps!

+0

Super, merci !! – LenaH