MATLABButtonDownFcn
のFigure でを使用しようとしています。imagesc
ツールバーに作成したカスタム ボタンをクリックして、この機能を有効にしたいと考えています。
ButtonDownFcn
は、 を使用して選択されたピクセルの位置を返すメソッドを呼び出します。ButtonDownFcn
これにより、そのピクセルが時間の経過とともにどのように変化するかをグラフ化できます。
注:
- 私は matlab で GUIDE を使用しています -
3Dimagesc
マトリックスをプロットしています。GUIDE で作成したボタンを使用して、時間の経過と共に画像がどのように変化するかを確認できるコードを既に実装しています。
現時点で私が苦労しているのButtonDownFcn
は、imagesc
. これを行う方法について(インターネットでの調査を通じて)何度も読みましたが、うまくいかないようです。
どんな助けでも大歓迎です。
これが私のコードです:
% --------------------------------------------------------------------
function ui_throughTime_ClickedCallback(hObject, eventdata, handles)
% hObject handle to ui_throughTime (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
valS = get(handles.txt_zaxis,'string');
display(valS);
val = str2num(valS);
d = handles.data;
m = imagesc(d(:,:,val),'parent',handles.axis, 'HitTest', 'off','buttondownfcn',{@getPlace, handles});
set(handles.axis,'buttondownfcn',{@getPlace, handles,m});
function getPlace(hObject,handles,event_obj,place)
% data = randn(120,160);
% ax = axes;
% imagesc(data,);
if (gcf == place)
pause(1);
cursor = get(handles.axis,'CurrentPoint'); % get point
% Get X and Y from point last clicked on the axes
x = (cursor(1,1));
y = (cursor(1,2));
disp(['x = ' num2str(x) ' y = ' num2str(y)]);
end