GUIDE code from pre 2015 need to access the button press function and "programatically press the button" from a different m file

조회 수: 1 (최근 30일)
Hey All
As the title suggests, I am dealing with a GUIDE file from a long time ago and I need to have it running and while its running I want to be able to access one of the functions called SaveSpectrumPlotButton_Callback() on line 1933
I have not been able to find how to access it from a different file or even create an output that I could maybe access in order to activate that button. I have shared the m file below
Any help would be much appreciated/
  댓글 수: 3
Bera
Bera 2024년 7월 17일
Hey Steven first off thanks. Secondly, I am a co-op working on this code that was given to me and to be frank its quite disorganized. In summary, the code itself is a live updating camera that feeds information to a spectroscope and makes a plot of the peak and then to save this data a button called save plot has to be saved. The issue arises that I am automating a giant process of quantum dots be excited and the light being extracted. So I have to implement this code into there i.e. I have to have the main function running while I can "progammitcally press" the save button every time I'm positioned on a new quantum dot

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

채택된 답변

Fangjun Jiang
Fangjun Jiang 2024년 7월 17일
In the .m file created for your GUIDE application, there is a function called SaveSpectrumPlotButton_Callback() defined. Currently, it is a local function. Other .m file outside of the FWHM_ver_Richard.m file can not call it.
I think you can cut the code for SaveSpectrumPlotButton_Callback() out and make it a separate SaveSpectrumPlotButton_Callback.m file. Then you can call this function from anywhere.
Calling it from other .m file will be equivalent as " programatically press the button".
  댓글 수: 32
Voss
Voss 2024년 7월 23일
@Bera: Looks like you have to specify a duration, duration unit, period, and period unit first.
Fangjun Jiang
Fangjun Jiang 2024년 7월 23일
Okay, that makes sense. You are writing code to mimic the effect of pushing a button on that GUI, so the necessary fields of that GUI should all provide valid input. Make sure you can do it manually first and then try your code.

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

추가 답변 (1개)

Image Analyst
Image Analyst 2024년 7월 17일
I agree with @Steven Lord that you should just rethink and reorganize the workflow. That said, please read the FAQ for ideas on how to control one GUI from another:
especially the section that begins "Sharing between multiple GUIs."

카테고리

Help CenterFile Exchange에서 App Building에 대해 자세히 알아보기

제품


릴리스

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by