Matlab GUI Question

1 view (last 30 days)
Steven
Steven on 18 Dec 2011
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

Accepted Answer

Walter Roberson
Walter Roberson on 18 Dec 2011
At the end of the callback, add
guidata(hObject, handles)

More Answers (0)

Categories

Find more on App Building in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!