Matlab GUI Question

조회 수: 4 (최근 30일)
Steven
Steven 2011년 12월 18일
I am trying to save variables after a button push for example when I push a button in my GUI and I modify a picture I want it to remember that I did it and the next time I modify the picture it will show the new picture
Here is the function I am having trouble with
% --- Executes on button press in AddDefecct.
function AddDefecct_Callback(hObject, eventdata, handles)
%Gets information from the radio buttons
Check(1) = get(handles.RedSubpixel,'Value');
Check(2) = get(handles.GreenSubpixel,'Value');
Check(3) = get(handles.BlueSubpixel,'Value');
Check(4) = get(handles.RedGreenSubPixel,'Value');
Check(5) = get(handles.RedBlueSubPixel,'Value');
Check(6) = get(handles.BlueGreenSubPixel,'Value');
Check(7) = get(handles.Pixel,'Value');
%Using the information from the radiot buttons to describe how to modify
%the picture
if Check(1) == 1
Type = [1,0,0];
elseif Check(2) == 1
Type = [0,1,0];
elseif Check(3) == 1
Type = [0,0,1];
elseif Check(4) == 1
Type = [1,0,0,0,1,0];
elseif Check(5) == 1
Type = [1,0,0,0,0,1];
elseif Check(6) == 1
Type = [0,0,1,0,1,0];
elseif Check(7) == 1
Type = [1,1,1,1,1,1,1,1,1];
end
%Checks if this is the first modification
A = exist('handles.PicData','var');
if A == 0 %Checks if it is the first
handles.PicData = imread('BlankBoE.jpg');
end
%Adds defect and outputs the new picture data
PicData = Adddefect(Type,handles.PicData);
%Trying to save the new picture data
handles.PicData = PicData;
I guess in a nutshell I am asking how to know whether or not it is the first time this button as been pushed
Any help would be appreciated
Thanks
Steven

채택된 답변

Walter Roberson
Walter Roberson 2011년 12월 18일
At the end of the callback, add
guidata(hObject, handles)
  댓글 수: 1
Steven
Steven 2011년 12월 18일
thx durr I am dumb

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Debugging and Analysis에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by