필터 지우기
필터 지우기

Custom context menu in the current folder to open .mat file using a script

조회 수: 1 (최근 30일)
Andrea Amorosi
Andrea Amorosi 2022년 8월 31일
답변: Vidip Jain 2023년 10월 5일
I have a script throug which I open some .mat files.
I would like to create a custom context menu in the current folder so that I can select the .mat file, select the custom menu voice and have the file name and path passed to the script which will open the .mat doing some things before and after opening it.
Is it possible to do that? How?
Otherwise is it possible to create an app and drag and drop the mat file to the app icon which will then call the script?

답변 (1개)

Vidip Jain
Vidip Jain 2023년 10월 5일
I understand you want to create a custom context menu in the current folder such that you can select the .mat file and have the file name and path passed to the script which will open the .mat file.
To create a custom context menu in the current folder, you can use the ‘uicontextmenu’ function in MATLAB. The ‘uicontextmenu’ function creates a context menu that can be attached to any UI object, including figures and axes objects.
To create a custom context menu for the current folder, you can follow these steps:
  1. Create a new MATLAB script file.
  2. Create a new context menu object using the ‘uicontextmenu’ function.
  3. Add a menu item to the context menu object using the ‘uimenu’ function.
  4. Set the callback function for the menu item to the script that you want to run when the menu item is selected.
  5. Attach the context menu object to the current folder using the 'set' function.
For further information, refer to the documentation links below:

카테고리

Help CenterFile Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by