is it possible to create a matlab script directly from gui pushbutton events (kind of like command line history)?

조회 수: 3 (최근 30일)
I created a GUI in appdesigner to do various manipulations of the raw (time domain) MRI data. After various combinations of buttons clicks, I would like to save that combination as a *.m script, so that I can come back a year from now to the dataset and reproduce the data processing protocol. Not as a batch mode within the interface, but have the actual *.m script explicitely specifying each step.
E.g. In the GUI interface: Action 1: subtract dc offset, Action 2: Multiply the data by a gaussian filter, Action 3: FFT
At the end of 3 button pushes, I want to get a script *.m:
data1=dc_offset(data0)
data2=data1*gaussfilter;
data3=fft(data2).
.... there can be 10 or 15 pushbuttons events that I essentially would like to save to a script and store this with the original dataset.
Thank you!
  댓글 수: 1
Jiri Hajek
Jiri Hajek 2023년 1월 25일
편집: Jiri Hajek 2023년 1월 25일
Hi, in principle, I;m not aware of any ready-to use or diary-like way to recort the sequence that would not require additioal coding. However, if you are not using the diary command in your app for other purposes, I'd still consider it a good way to output the desired lines of code to a text file. M-file is a simple text file after all.
I've been using diaries in apps to create log files for years, in this case it's essentially the same concept.

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

답변 (1개)

Rik
Rik 2023년 1월 25일
편집: Rik 2023년 1월 25일
If you don't use numbered variables, you can include an fprintf statement that will write a line to a text file. There is no automated way to extract the text of the current function, so you will need to manually create that.
I doubt diary will work in the context of callbacks, but if you like that idea you can give it a try. If it does work, the downside will be that you van only have 1 at a time, while you can have about 200 log files open at a time if you use fopen.

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by