2019-07-17 14:51发布
tulin 发表于 2012-4-12 16:27 另外记得整个结束后同步handles和hObject
if 循环就是为了画直线 点击两点画直线。应该是在红 {MOD}部分加算平均值 且是完成每个if循环后,即直线画完后求平均handles.lengthPoints = [handles.lengthPoints ; x y]; hPlot = plot(x*A,y*A,'g.','markersize',10,'tag','point'); handles.hLengthPointsPlot = [handles.hLengthPointsPlot ; hPlot]; for j=1:2:100 if size(handles.lengthPoints,1)==j+1 points = A*handles.lengthPoints([j j+1],:); hLine = plot(points(:,1), points(:,2), 'g', 'linewidth',2, 'ButtonDownFcn','calcArea(''axes1_ButtonDownFcn'',gca,[],guidata(gcbo))'); handles.lengthLines = [handles.lengthLines hLine]; dist = sqrt( sum((diff(points).^2)) );%前面有diff的定义 orientation = angle( diff(points) * [1 ; i] );%angle()是求相位角,angle()的取值是-pi到pi h = text(mean( points(:,1) ), mean( points(:,2) ) , num2str(dist), 'Rotation', orientation);% 在中点位置显示直线长度 handles.hLengthData = [handles.hLengthData h]; temp = get(handles.totalArea,'userdata'); temp(3) = (temp(3) +dist);%求总和 set(handles.totalArea,'userdata',temp); end set(handles.totalArea,'userdata',temp); updateTitle(handles); end guidata(hObject,handles);% guidata保存数据 更新数据
最多设置5个标签!
哦 谢谢 你能帮我看一段小程序吗?我求每条直线的平均值 可是只能算出总值 不知道怎么改 不太懂句柄
一周热门 更多>