1
我是matlab新手,我被卡住了回調函數以繪製來自工作區的數據。在我的代碼中,按鈕1和2允許我將數據導入到工作空間('importTac'和'importref'是單獨的m.files,用於將數據導入到工作空間並且它們工作正常)。UIcontrol按鈕來繪製matlab中的工作空間數據
我的問題是如何通過點擊pushbutton_3來繪製工作區中的數據?
function KinA
%Configure window
h.fig = figure('MenuBar', 'none','units','pixels','Position', [0 0 1280 750],... % [x,y,width, height]
'name','KinA | Kinetic Analysis','numbertitle','off','Resize', 'off');
tgroup = uitabgroup('Parent', h.fig);
% Define tabs
tab1 = uitab('Parent', tgroup, 'Title', '1| IMPORT DATA');
tab2 = uitab('Parent', tgroup, 'Title', '2| Dynamic parameters');
tab3 = uitab('Parent', tgroup, 'Title', '3| Dynamic plots');
tab4 = uitab('Parent', tgroup, 'Title', '4| Volume of distribution, DVR');
%CONTENT ON TAB1: importdata, plot TAC and
handles.button_1 = uicontrol('Parent', tab1, 'Style','pushbutton',...
'String','Import TACs','Position',[20 650 120 25], 'Callback', 'importTac'); % [x,y,width, height]
handles.button_2 = uicontrol('Parent', tab1, 'Style','pushbutton',...
'String','Import reference','Position',[20 620 120 25], 'Callback', 'importRef'); % [x,y,width, height]button_importReference = uicontrol
handles.button_3 = uicontrol('Parent',tab1, 'Style','pushbutton',...
'String','Plot raw data','Position',[20 590 120 25], 'Callback',{@plot_data,handles});
%Define axes
handles.ax1 = axes('Parent', tab1 , 'units', 'pixels', 'Position',[200 450 300 200]);
set(gca, 'tickdir', 'out', 'box', 'off', 'FontSize', 14 ,'Color',[0.8 0.8 0.9]);
xlabel('Time [min]', 'FontSize', 12, 'FontName', 'Arial');
ylabel('Activity [kBq]', 'FontSize', 12, 'FontName', 'Arial');
%Callback function
end
變量如何'importTac'和'importRef'定義?他們會回報什麼嗎? –
感謝您的快速回復。 importTac和importRef由uigetdir和uigetfile定義。他們工作正常。 我想通了。我用evalin訪問工作空間中的變量 %回調函數TAC情節 功能plot_data(源,EVENTDATA) 時間= evalin( '基', 'xValues'); brain = evalin('base','y1Values'); input = evalin('base','y2Values'); p1 = plot(handles.ax1,time,brain) p2 = plot(handles.ax2,time,input) end –