这对我来说是第一次。我已经开始使用GUIDE了,经过温和的诅咒,我已经触底了。我在m文件中设置了一个计数器但由于某种原因它没有更新。请你帮助我好吗。该计数器名为num。
function ack = streamSensor_1_2_3(hObject, handles)
if handles.fileID.BytesAvailable == 0
fprintf(handles.fileID, 'P')
display('yes');
%get data from active receiver stations
for l = 1:3
data_cm(l,:) = fscanf(handles.fileID, ' %f ' );
display(data_cm);
set(handles.uitable1, 'data', data_cm);
end
%solve perpendicular view
[at, bt, ct] = flatPlane(data_cm(:,2), data_cm(:,3), data_cm(:,4))
[xr, yr] = reposit(at, bt, ct);
D_angle = dangle(data_cm(:,2), data_cm(:,3), data_cm(:,4), 'deg');
display(handles.num);
comet(handles.axes3, handles.num, D_angle);
handles.num = handles.num +1 ;
%plot knee angle
plot3(handles.axes1, data_cm(:,2), data_cm(:,3), data_cm(:,4));
plot(handles.axes2, xr, yr);
ylim(handles.axes2,[-1.2 1.2]);
xlim(handles.axes2,[-1.2 1.2]);
ack = 1;
else
ack = 0;
end
guidata(hObject, handles);
我在开场函数
中声明了这个变量function Knee_DepressAngle_GUI_OpeningFcn(hObject, eventdata, handles, varargin)
% Choose default command line output for Knee_DepressAngle_GUI
handles.output = hObject;
handles.num = 0;
% Update handles structure
guidata(hObject, handles);
...........etc.
按下按钮调用该功能。这后来将成为一个连续调用的函数,因此基于按钮按下信息的计数器将不起作用。
function printOnce_Callback(hObject, eventdata, handles)
display(streamSensor_1_2_3(hObject, handles));
guidata(hObject, handles);
答案 0 :(得分:0)
在按钮的回调功能中,除非您的guidata(hObject, handles);
函数返回更新后的streamSensor_1_2_3()
,否则请勿再次致电handles
。因此,只需删除函数printOnce_Callback(hObject, eventdata, handles)
中的最后一行。