Can I call another application using MatLab function?
Mostrar comentarios más antiguos
Excuse me, I'm a newbie in MatLab, I've ever read about calling office application, Can I call another application using MatLab function and command it to do some certain task? Thank you
Respuestas (3)
Image Analyst
el 2 de Jun. de 2013
Yes. Use the system() command. Just pass it the string with the name of the app you want to launch, plus any command line arguments. For example, here's a script that will launch Photoshop:
clc;
%----------------------------------------------------------------------
% Get the name of the image file. Get the full filename, with path prepended.
% Use a standard MATLAB color demo image.
folder = fullfile(matlabroot, '\toolbox\images\imdemos');
baseFileName = 'peppers.png';
% Get the full filename, with path prepended.
fullImageFileName = fullfile(folder, baseFileName);
if ~exist(fullImageFileName, 'file')
% Didn't find image. Alert user.
errorMessage = sprintf('Error: image\n%s\ndoes not exist.', fullImageFileName);
uiwait(warndlg(errorMessage));
return;
end
% Check to see that Photoshop executable exists.
editorFullFileName = 'C:\Program Files\Adobe\Adobe Photoshop CS5 (64 Bit)\Photoshop.exe';
if ~exist(editorFullFileName, 'file')
errorMessage = sprintf('Cannot find the Photoshop program.\n%s', editorFullFileName);
uiwait(warndlg(errorMessage));
return;
end
% Now run the Photoshop program, passing in the image filename.
% First construct the command line for the system() function.
% Enclose all filenames in double quotes because we may have spaces in the filenames.
arguments = sprintf('"%s"', fullImageFileName);
commandLine = sprintf('"%s" %s', editorFullFileName, arguments);
fprintf('%s', commandLine);
% Now launch the Photoshop program using the "system()" function.
system(commandLine);
Azzi Abdelmalek
el 2 de Jun. de 2013
Editada: Azzi Abdelmalek
el 2 de Jun. de 2013
To run external application use ! operator. Example
! dir
As'adul
el 2 de Jun. de 2013
0 votos
Categorías
Más información sobre Introduction to Installation and Licensing en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!