.. unfortunaltyプロットから座標を抽出
function process_plot()
dataset_dia = input('diameter?')
dataset_length = input('length?')
h = gcf;
a = gca;
f =get(gca,'Children');
set(h, 'Pointer', 'fullcrosshair');
set(f,'ButtonDownFcn',{@Click_CallBack a});
save(strcat(dataset_dia, '.mat'), x, y);
end
機能は動作しません。左クリックしてポイントをユーザデータに保存し、MATファイルに書き込むための選択が完了したら右クリックします。
function process_plot()
f =get(gca,'Children');
set(gcf, 'Pointer', 'fullcrosshair');
set(f,'ButtonDownFcn',{@Click_CallBack gca});
function [x, y]= Click_CallBack(h,e,a)
userData = get(a,'userData'); %Store x,y in axis userData
switch get(ancestor(a,'figure'),'SelectionType')
case 'normal' %left click
point = get(a,'CurrentPoint');
userData(end+1,:) = [point(1,1) point(1,2)];
set(a,'userData',userData)
fprintf(1,'X,Y = %.2f,%.2f\n',point(1,1),point(1,2));
otherwise %alternate click
% Reset figure pointer
set(ancestor(a,'figure'), 'Pointer','arrow');
%Clear button down fcn to prevent errors later
set(get(gca,'Children'),'ButtonDownFcn',[]);
%Wipe out userData
set(a,'userData',[]);
x = userData(:,1);
y = userData(:,2);
save('myMatFile', 'x', 'y'); %Save to MAT file ... replace name
end
もちろん、軸ユーザーデータを使用していない場合はもちろんです。また、ボタンを押している間に取得された現在の点は、実際にプロットされたデータセットには含まれません。あなたの描いた線上のカーソルの現在の位置です。プロットされた行に実際の点が必要な場合は、取得したカーソル位置に最も近い点をデータ内で検索する必要があります。
GUIでのデータ通信のテーマに関するMatlabの関連ドキュメントの一部を読んでください。あなたのケースで役立つと思います。[プログラムによるGUIでデータを管理する方法](http:// www.mathworks.fr/help/techdoc/creating_guis/f13-998352.html)と[GUIコールバックのデータを共有する](http://www.mathworks.fr/help/techdoc/creating_guis/f13-998449.html# f13-1000011) – Aabaz