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

Stephen23
Stephen23 2018년 4월 13일
" 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

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

답변 (0개)

카테고리

도움말 센터File Exchange에서 Programming에 대해 자세히 알아보기

질문:

2018년 4월 13일

댓글:

2018년 4월 13일

Community Treasure Hunt

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

Start Hunting!

Translated by