Getting Windows to open a file type using a MATLAB application
조회 수: 3 (최근 30일)
이전 댓글 표시
I'd like to create a MATLAB application that can be used by Windows as the default program for opening certain file types. What I'm imagining is creating an app that reads an Excel file and processes and displays the information in a certain way. I would save an Excel file as something.xls2, and when I click on it in the file explorer, it would start my MATLAB application and pass it the filepath of something.xls2 so that the app can read the data and do it's thing. If this is possible then I'm sure it would involve some fiddling with Windows as well as MATLAB, but any insight would be appreciated.
댓글 수: 0
답변 (2개)
Rik
2021년 5월 28일
You should be able to compile your function and use the 'open with' dialog in Windows to assign it to your exe.
If you let your function accept the path as input this should work without any tricks.
댓글 수: 0
per isakson
2021년 5월 28일
편집: per isakson
2021년 6월 1일
An alternative that doesn't require the Matlab compiler (but requires a Matlab license to run):
- Create a bat-file, e.g. read_xls2.bat (See Guide to Windows Batch Scripting). (Or a PowerShell script.)
- Right click an xls2-file, click "Open with ...", and choose read_xls2.bat as "Always open with"
- Create an m-file, read_and_process_xls2.m, that does the job.
- read_xls2.bat shall contain a command that starts Matlab, see matlab (Windows), Start MATLAB program from Windows system prompt and Commonly Used Startup Options. The name of the xls2-file that you double click will be available in the batch file under the name "%1" (and "%*"). The strings "read_and_process_xls2", "-batch" (or "-r") and "%1" shall appear in the command line that starts Matlab.
I made a tiny demo. Double clicking echo.abc invokes echo.bat
ECHO %0
ECHO %1
ECHO %*
pause
outputs
D:\m\cssm>ECHO "D:\m\cssm\echo.bat"
"D:\m\cssm\echo.bat"
D:\m\cssm>ECHO "D:\m\cssm\echo.abc"
"D:\m\cssm\echo.abc"
D:\m\cssm>ECHO "D:\m\cssm\echo.abc"
"D:\m\cssm\echo.abc"
D:\m\cssm>pause
Press any key to continue . . .
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Environment and Settings에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!