How to save all my matlab plots from for loop?
Mostra commenti meno recenti
Hello Everyone,
I am trying to save all my plots from my for loop into a word document. I have tried using save2word, but that only saves the last figure from the for loop. If anyone can give me some insight on what I can add to my script, such that I am able to export all plots from MATLAB into a Word doc. It will be most appreciated.
Also, I tried using the print function, and that didn't work for me yet either.
Sincerely,
Robert
CODE:
fName = 'SHOCK2019Graphs.doc'
if exist(fName,'file')
delete(fName)
end
wordHand = save2Word(fName);
for q = 1:16
figure(q)
plot(SBOB{1}.tt,SBOB{1}.Acc(:,q))
hold on
plot(SBridge{5}.tt,SBridge{5}.Acc(:,q))
title(SBOB{1}.labels(q)),xlabel('Time, Measured in Seconds'), ylabel('Acceleration, Measured in ft/sec^2')
legend('Bridge on Box','Bridge','location','northeast')
filename = 'Test.pdf';
print(figure(q),'-dpdf',filename);
end
save2Word(fName,wordHand)
3 Commenti
Walter Roberson
il 23 Set 2019
Perhaps
fName = 'SHOCK2019Graphs.doc'
if exist(fName,'file')
delete(fName)
end
wordHand = save2Word(fName);
h = gcf;
ax = gca;
for q = 1:16
%figure(q)
plot(ax, SBOB{1}.tt,SBOB{1}.Acc(:,q))
hold(ax, 'on')
plot(ax, SBridge{5}.tt,SBridge{5}.Acc(:,q))
hold(ax, 'off')
title(ax, SBOB{1}.labels(q)),xlabel('Time, Measured in Seconds'), ylabel('Acceleration, Measured in ft/sec^2')
legend(ax, {'Bridge on Box','Bridge'},'location','northeast')
filename = 'Test.pdf';
print(fig,'-dpdf',filename);
save2Word(fName, filename);
end
Robert Flores
il 23 Set 2019
Walter Roberson
il 23 Set 2019
h = gcf;
ax = gca;
should have been
fig = gcf;
ax = gca(fig);
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Language Support in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!