Matlab GUI Question

1 回表示 (過去 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 Center および File ExchangeEnvironment and Settings についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by