Clear vairables in workspace using gui pushbutton callback??

조회 수: 12(최근 30일)
Brasco , D.
Brasco , D. 2015년 1월 26일
댓글: Geoff Hayes 2021년 1월 4일
Hi guys,
here is my problem:
i load a mat file that contains several variables before i run my gui. I use these variables with the help of "evalin" command in my gui callbacks.
Let say my workspace variables are these : A cell , B cell , C double,... goes on.
I want to clear all variables in the workspace window using a push button callback.
" I want to clear variables that i loaded before i run my gui".
(i read some answers and there was a conflict about the workspace term. I MEAN THE VARIABLES APPER IN MATLAB WORKSPACE WINDOW, NOT THE GUI WORKSPACE. )
  댓글 수: 2
Geoff Hayes
Geoff Hayes 2021년 1월 4일
Pathmashantha - you may want to elaborate on what you need help with.

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

채택된 답변

Geoff Hayes
Geoff Hayes 2015년 2월 1일
Ozgur - if there are specific variables that you want to clear from the MATLAB (base) workspace, then you could use evalin with clear. If you put the following line in a push button callback, then
evalin('base','clear A B')
would clear the variables A and B that are in your base workspace.
But why are there variables in your base workspace that you need to evaluate in your GUI? Why not pass them as inputs to the GUI upon startup, or load them from a mat file and so avoid all of the evalin calls (which make troubleshooting bugs somewhat difficult).
  댓글 수: 1
Brasco , D.
Brasco , D. 2015년 2월 2일
Thak you for your help. You are right. I read alot about evalin bugs, but i am newbe and dont know much about the gui. Thanks for the advise. I will try to do things as you mentioned. I have to read helps about gui and the passing variables as inputs to gui.. thing. Thank you again.

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

추가 답변(1개)

HAMZA ABBASI
HAMZA ABBASI 2018년 6월 24일
clear object name like (clear a) will not work.... write clear all statement in the first line of code

Community Treasure Hunt

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

Start Hunting!

Translated by