数据是离散的A[s h] ,我用plot画出了二维曲线,我想在鼠标按下后,就添加一些点并添加到原来矩阵里.下面是我用已知函数做的测试可行,但到离散的我就不会了,而且也只是添加了点,并不知道怎么保存,各位大师,麻烦指点。
x = 1:0.1:2*pi;
y = sin(x);
plot(x,y);
tempA = [ x' y'];
handles.tempA = tempA;
guidata(hObject,handles);
func
tion figure1_WindowButtonDow
NFCn(hObject, eventdata, handles)
% hObject handle to figure1 (see GCBO)
% eventdata reserved - to be defined in a future version of
matlab
% handles structure with handles and user data (see GUIDATA)
tempA = handles.tempA;
currPt = get(gcf, 'CurrentPoint');
x = currPt(1,1);
y = currPt(1,2);
tempA_R = tempA(1:end,1);
n = find(tempA_R > x,1,'first');
xx = (tempA(n-1,1) + tempA(n-2,1)) / 2;
yy =S(find(x==xx));
hold on;
plot(x,y,'p');
hold off;
一周热门 更多>