0
算法加載兩個圖像並顯示它。用戶可以選擇其中一個圖像並將其拖過屏幕。目標是讓用戶能夠覆蓋圖像。評估圖中的錯誤WindowButtonDownFcn-未定義的函數在MATLAB指南類中
有兩個腳本1)Main.m和2)gui_class。腳本Main.m包含gui函數和回調。 gui_class用於加載圖像並模擬啓動圖像拖動功能的點擊。
在classdef gui_class < handle
在於
properties (Access = private)
x = [];
y = [];
c1 = [];
r1 = [];
h = [];
w = [];
gui_h;
end
methods
%function - class constructor - creates and init's the gui
function this = gui_class
%make the gui handle and store it locally
this.gui_h = guihandles(Main);
%set the callback functions
set(this.gui_h.load_image ,'callback' ,@(src, event) load_image_Callback(this, src, event))
end
end
` methods (Access = private)
function this = load_image_Callback(this, src, event)
%code loads and displays images here
%trigger a mouse click
set(gcf,'windowbuttondownfcn',@(src, event) Mclicked(src, event));
end
function Mclicked(this, src, event)
% get the handles structure
set(gca,'units','pix') ;
mousePositionData = get(gca, 'CurrentPoint')
this.x = mousePositionData(1,1);
this.y = mousePositionData(1,2);
%...Perform task
end
我得到一個錯誤信息:錯誤而MATLAB指導課 未定義功能「Mclicked」類型「雙」的輸入參數範圍內評估數字WindowButtonDownFcn-未定義功能。在gui_class/load_image_Callback/@(SRC,事件)Mclicked(SRC,事件)
錯誤
怎樣一個人準確地正確地調用這個函數呢?除了這個問題之外,爲什麼會發生這種情況呢? 我在它的main.m下面說明如所提到的:
function Mclicked(hObject, eventdata, handles)