필터 지우기
필터 지우기

How to pass a variable to a function in GUI?

조회 수: 1 (최근 30일)
Salad Box
Salad Box 2018년 2월 26일
댓글: Salad Box 2018년 2월 26일
Hi,
Please see the graphs shown below.
In part A (the part which will execute when button is pressed), you can see that I am trying to load a .mat file. There is a variable called 'RGB' saved in this .mat file.
And in part B, I am also trying to use the same variable RGB without loading it again.However, the RGB from part A would not be passed to part B just like that.
I also tried in part A I wrote:
handles.RGB=RGB;
and in part B I wrote:
RGB= handles.RGB
But it didn't work. Could anyone help please?
  댓글 수: 3
Stephen23
Stephen23 2018년 2월 26일
편집: Stephen23 2018년 2월 26일
Rather than using the command syntax of load it is recommended to use the function syntax, and load into an output variable (which is a structure). This will make it more obvious that the data has been loaded into that callback's workspace only:
S = load('Picture.mat');
handles.RGB = S.RGB;
guidata(hObject, handles) % you forgot this!
Salad Box
Salad Box 2018년 2월 26일
Thank you both! After I posted this article, I did realize I missed
guidata(hObject, handles);
Thank you again!!!!!

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

채택된 답변

Adam
Adam 2018년 2월 26일
Personally I use guidata if I am creating a GUIDE UI, but there are various different approaches in that link

추가 답변 (0개)

카테고리

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