Matlab GUI Question

4 Ansichten (letzte 30 Tage)
Steven
Steven am 18 Dez. 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

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 18 Dez. 2011
At the end of the callback, add
guidata(hObject, handles)
  1 Kommentar
Steven
Steven am 18 Dez. 2011
thx durr I am dumb

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Debugging and Analysis finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by