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

3 vues (au cours des 30 derniers jours)
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 commentaire
Jiri Hajek
Jiri Hajek le 25 Jan 2023
Modifié(e) : Jiri Hajek le 25 Jan 2023
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.

Connectez-vous pour commenter.

Réponses (1)

Rik
Rik le 25 Jan 2023
Modifié(e) : Rik le 25 Jan 2023
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.

Catégories

En savoir plus sur Migrate GUIDE Apps dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by