0
プロットの可視性が2つの異なる軸でのチェックボックスの選択によって制御されるGUIを準備しています。さらに、ユーザは、ポップアップメニューからYベクトルを選択する必要があります。コードは正常に動作しています(それはよりエレガントです)が、プロットを自動的にリフレッシュする際の問題があります。現在、プロットしてポップアップメニューから別のY値を選択した場合は、チェックを外して、プロットで行われる変更のチェックマークを再確認する必要があります。 GUIが選択されていれば、プロットを自動的にリフレッシュさせるにはどうすればいいですか(チェックマーク)。すべてのヘルプははるかに高く評価されています。ここではGUIプロットの継続的更新
は私のコードです:
% --- Executes on pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
X=[1 2 3 4]
Y1=[10 20 30 40]
Y2=[-1 -2 -3 -4]
handles.X=X;
handles.Y1=Y1;
handles.Y2=Y2;
guidata(gcbo, handles);
UnitFcn(handles)
% --- checkbox function on/off
function C = OnOffStr(D)
OffOn = {'off', 'on'};
L = (D ~= 0) + 1; % 0/FALSE => 1, anything else => 2
if length(L) == 1
C = OffOn{L}; % Reply a string
else
C = OffOn(L); % Reply a cell string
end
function UnitFcn(handles)
Y1=handles.Y1;
for p = 1:numel(plotdata)
Unit = get(handles.popupmenu1,'Value');
if (Unit==1)
Y(:,p)=Y1(:,p);
elseif (Unit==2)%
Y(:,p)=Y1(:,p)*100;
end
end
handles.Y=Y;
guidata(gcbo, handles);
PlotFcn(handles)
function PlotFcn(handles)
X=handles.X;
Y=handles.Y;
Z=handles.Y2;
%Plot in Axes 1
set(handles.axes1, 'NextPlot', 'add');
handles.plot1 = plot(X,Y,'visible','off','LineWidth',2, ...
'color', [0 0 0],'linestyle', '--', 'parent', handles.axes1);
%Plot in Axes 2
set(handles.axes2, 'NextPlot', 'add');
handles.plot2 = plot(X,Y2,'visible','off','LineWidth',2, ...
'color', [0 0 0],'linestyle', '--', 'parent', handles.axes2);
guidata(gcbo, handles);
% --- Executes on button press in checkbox1.
function checkbox1_Callback(hObject, eventdata, handles)
set(handles.plot1, 'Visible', OnOffStr(get(hObject,'Value')));
% --- Executes on button press in checkbox1.
function checkbox1_Callback(hObject, eventdata, handles)
set(handles.plot2, 'Visible', OnOffStr(get(hObject,'Value')));
% --- Specify unit in popupmenu1.
function popupmenu1_Callback(hObject, eventdata, handles)
UnitFcn(handles)
function popupmenu1_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
これは単純化されたコードとある「P = 1:numelの(plotdata)は、」私は違う〜30を持つマトリックスを参照してください。プロット