弹出菜单和图形焦点在Matlab中

时间:2015-01-30 01:10:54

标签: matlab matlab-figure matlab-guide

所以我在GUI中有这个,它用给定的x,y和z坐标绘制散点图。

function activation(hObject, eventdata, handles)

cla(handles.eeg_final,'reset')   
axes(handles.eeg_final)

x = [-30;-50;-40;-60;-60;-60;-30;30;60;60;60;40;50;30];
y = [50;30;30;0;20;-60;-80;-80;-60;20;0;30;30;50];
z = [30;0;40;30;0;0;10;10;0;0;30;40;0;30];

location={};
s=cell(1,14);
for a = 1:14
    location{1} = sprintf('AF3');
    location{2} = sprintf('F7');
    location{3} = sprintf('F3');
    location{4} = sprintf('FC5');
    location{5} = sprintf('T7');
    location{6} = sprintf('P7');
    location{7} = sprintf('O1');
    location{8} = sprintf('O2');
    location{9} = sprintf('P8');
    location{10} = sprintf('T8');
    location{11} = sprintf('FC6');
    location{12} = sprintf('F4');
    location{13} = sprintf('F8');
    location{14} = sprintf('AF4');
    n = location{a};
    s(a)=strread(sprintf(n),'%s','delimiter','');
end
% the plot
scatter3(-x,-y,-z,'filled'); % <- NOT <plot3>
text(-(x+.3),-(y-.5),-z,s,'color',[1,0,0]);
view(115,18)

然后我有一个绘图选项调用此函数和其他功能,这些功能专注于handles.eeg_final

function plot_options_popup_Callback(hObject, eventdata, handles)
% hObject    handle to plot_options_popup (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
str = get(hObject, 'String');
val = get(hObject, 'Value');

switch str{val};
    case 'EEG Plot - 14 Channel'
        return
    case 'Activation Plot'
        activation
    case 'Emotion State Plot'
        emotion_state
end

但是当我尝试拨打Activation Plot时,我收到一条错误消息,说“没有足够的论据。&#39;

谁能告诉我哪里出错?

1 个答案:

答案 0 :(得分:1)

错误,因为您使用3个输入参数编写了函数activation。您可以更改功能:

function activation(hObject, handles)

cla(hObject,'reset');
axes(hObject);

% do what you want here

% update handles struct at the end
guidata(hObject, handles);

并在弹出菜单中通过以下方式调用它:

activation(handles.eeg_final, handles);