creating GUI using existing code

I just finished a long and complicated program on matlab and should make a GUI for it everything I´ve found is telling me to re-write the code in the guide command or to call a function in the guide. but re-writing the code is impossible and the program doesn't have functions to call, it´s a series of loops and if-s.

2 Kommentare

Stephen23
Stephen23 am 13 Apr. 2018
" but re-writing the code is impossible and the program doesn't have functions to call"
If you want to write reliable code that can be integrated into a GUI then use functions. Scripts are basically useless for anything more complex than just testing out a new idea, and should be totally avoided for anything that is "long and complicated". You need to write functions.
i agree with Stephen and with the informations you have given it is hard to provide a better answer. Depending on what your program does and what the gui is supposed to do you could just wrap your code in a function and create a gui that executes it
GUI:
function glac()
%GUI for long and comlicated code
fig=figure;
pushbutton1=uicontrol('Style','pushbutton','String','Execute','callback',@lacf);
end
function lacf(~,~)
%long and complicated code function
disp('Hello Matlab!') %replace this with long and complicated code ?
end

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Programming finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 13 Apr. 2018

Kommentiert:

am 13 Apr. 2018

Community Treasure Hunt

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

Start Hunting!

Translated by