Hello Guys,
I am using the print function for creating eps files for my bachelor thesis.
print('filename' ,'-painters','-depsc', '-r300')
I have the following problem. The filenames of my diagrams are different depending on the experiment. I found out how to use the string function to create names for my diagrams by my inputs. And I am trying the same here.
For example:
name = string({'growthcurve'});
Now Matlab use name for the generation of the diagram title 'growthcurve'.
Is it possible to say the print function also that it should use the variable 'name' to name the file 'growthcurve'. Like print(name ,'-painters','-depsc', '-r300') and the filename then is growthcurve.eps?
Sorry for my english :)
Best wishes
Dennis

5 commentaires

Stephen23
Stephen23 le 8 Mar 2017
Modifié(e) : Stephen23 le 8 Mar 2017
What happened when you tried it?:
name = 'growthcurve.eps';
print(name,'-painters','-depsc', '-r300')
Dennis D.
Dennis D. le 9 Mar 2017
Well this worked. Thank you! This would be my option if there is no other way. Here is my "code" (I am a beginner so there might be some mistakes. So do not hit me ;-) ) Maybe with the code you can better understand what I want :-)
x = th ; y1 = E600nm; y2 = lnE600nm;
medium = string({'XYZ'});
replica = string({'Replica1'});
nameCurve = {'growthcurve', medium + ' ' + replica};
nameSemlog = {'semilogy growthcurve', medium + ' ' + replica};
figure
subplot(1,2,1);
plot(x,y1, 'b--.', 'Markersize', 12)
title(nameCurve)
xlabel('t * h^{-1}')
ylabel('oD_{600nm}')
grid on
grid minor
subplot(1,2,2);
semilogy(x,y1,'r--.', 'Markersize',12)
title(nameSemlog)
xlabel('t * h^{-1}')
ylabel('ln (oD_{600nm})')
axis([0 20 10E-2 inf])
grid on
grid minor
print('filename' ,'-painters','-depsc', '-r300')
So the titles of the plots are fine. I am looking for a possibility that I can say in the print command nameCurve and the filename is generated from the strings in this variable such as it works with the plot title.
i.e. print( nameCurve,'-painters', '-despc', '-r300') Then the plot is printed with the filename growthcurve XYZ Replica1.eps
Hope this explains it better :)
Rik
Rik le 9 Mar 2017
You're making it really difficult for yourself by using the string function and all those cells. They have there uses, but here they obfuscate the problem. Simply using single quotes will result in a string.
The reason why you can't just put your title as a file name is that your title is multiline. You could concatenate it with the code below.
medium = 'XYZ';
replica = 'Replica1';
nameCurve = {'growthcurve ', [medium ' ' replica]};
cell2mat(nameCurve)
print(nameCurve,'-painters','-depsc', '-r300')
PS for better readability of your code, select it and hit the {} code button.
Dennis D.
Dennis D. le 9 Mar 2017
Thanks for this quick answer and the tipp :-) But I got error messages!
Error using checkArgsForHandleToPrint Handle input argument contains nonhandle values.
Error in checkArgsForHandleToPrint
Error in print>LocalCreatePrintJob (line 216) handles = checkArgsForHandleToPrint(0, varargin{:});
Error in print (line 38) [pj, inputargs] = LocalCreatePrintJob(varargin{:});
Error in test (line 10) print(nameCurve,'-painters','-depsc', '-r300')
Rik
Rik le 9 Mar 2017
Hmm. The error tree suggests that the print function interprets nameCurve as a handle, which it isn't. Do you really need the interpreter do be set to '-painters'? Otherwise you might give it a try without that switch.

Connectez-vous pour commenter.

 Réponse acceptée

Thorsten
Thorsten le 9 Mar 2017

1 vote

medium = 'XYZ';
replica = 'Replica1';
nameCurve = ['growthcurve', medium, ' ', replica];
nameSemlog = ['semilogy growthcurve', medium, ' ', replica];
print(nameCurve, '-painters', '-depsc', '-r300')

Plus de réponses (0)

Catégories

En savoir plus sur Printing and Saving 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!

Translated by