I have a MATLAB application I have written on a Windows10 system which I will compile for Windows, Mac, and Unix. I am using the winopen function in my code which works in my Wondows10 platform. Will it compile OK for Windows use and will it also work for the Mac and Unix compilations?

답변 (2개)

Jonathan
Jonathan 2021년 2월 11일

1 개 추천

Eventually found an answer to this problem, with some help for MATLAB, which was to open a PDF document:
% Open the PDF in the system Adobe application
if (ispc)
winopen(pdfPath);
elseif ismac
cmdToExecute = ['open ' pdfPath];
[status, path] = system(cmdToExecute); %#ok<ASGLU>
else
% using xdg-open to open a file in Linux. Some Linux systems might not have
% xdg-open .In that case displaying as error with the file path
cmdToExecute = ['xdg-open ' pdfPath];
[status, path] = system(cmdToExecute); %#ok<ASGLU>
end
Steven Lord
Steven Lord 2020년 5월 20일

0 개 추천

winopen will throw an error on non-Windows platforms.

댓글 수: 2

Jan Prochazka
Jan Prochazka 2021년 2월 11일
편집: Jan Prochazka 2021년 2월 11일
Is there alternative that will not throw an error but open the file?
Steven Lord
Steven Lord 2021년 2월 11일
It depends on the file format. If MATLAB knows how to open a specific file format you could use the open function. If MATLAB does not know how to open your specific file format you could extend the functionality of open by writing your own file handling function as described in the documentation page for the open function.
If like Jonathan you're trying to open a PDF that is one of the extensions listed in the description of the name input argument as being supported.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

제품

릴리스

R2019b

질문:

2020년 5월 20일

댓글:

2021년 2월 11일

Community Treasure Hunt

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

Start Hunting!

Translated by