to print file to particular location

3 visualizaciones (últimos 30 días)
Farzeen
Farzeen el 10 de Nov. de 2019
Respondida: Image Analyst el 10 de Nov. de 2019
I was want to save file in a different folder.
print('answer\Case_A','-dpdf','-bestfit'); %works fine
Tried the code below to print file in a for loop and to save each case in a different folder.
cas={'Case_A','Case_B','Case_C','Case_D','Case_E','Case_F','Case_G','Case_H'};
file=strcat('answer\',cas(dataset)); %dataset being loop variable.
print(file,'-dpdf','-bestfit');
Gives error as below:
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 TestPSCAD_MM_L1_case (line 52)
print(file,'-dpdf','-bestfit');

Respuesta aceptada

Image Analyst
Image Analyst el 10 de Nov. de 2019
Try this:
cas = {'Case_A','Case_B','Case_C','Case_D','Case_E','Case_F','Case_G','Case_H'}
outputFolder = fullfile(pwd, '/answer') % or wherever you want.
for k = 1 : length(cas)
baseFileName = sprintf('%s.pdf', cas{k}) % Use braces around k, NOT parentheses.
fullFileName = fullfile(outputFolder, baseFileName)
print(fullFileName,'-dpdf','-bestfit');
end

Más respuestas (0)

Categorías

Más información sobre Entering Commands en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by