2011-12-07 109 views
0

這是我的GUI的一部分,當我在按鈕Matlab的GUI錯誤

// 
// 
// 
%VERIFICATION 
% --- Executes on button press in pushbutton9. 
function pushbutton9_Callback(hObject, eventdata, handles) 
% hObject handle to pushbutton9 (see GCBO) 
DIR=handles.directory; 
%angle=Angles(DIR); 
area=nor_area(DIR); 
%area=0.002; 
%display(area) 
Check=verify(area); 
%display(Check); 
if(Check==0) 
%message = sprintf('nClick the OK button to continue'); 
msgbox('The signature belongs to the same person!!!'); 
else 
msgbox('The signature is forged!!!'); 
end 

// 
// 
// 

單擊它執行,這是驗證功能

// 
// 
// 
function flag= verify(area) 
%area=0.8969; 
%take=area; 
%display(take) 
flag=0; 
extract = xlsread('D:\Project\Image_processing\important\best.xlsx', 'CW4:CW17'); 
c=size(extract); 
%display(c) 
for k = 1:c 
if (extract(k)==area) 
     display(extract(k)); 
     flag=1; 
    end 
end 
%display(flag) 
// 
// 
// 

best.xlsx是從Excel文件我正在檢索這些值並與我從主gui函數獲得的值進行比較。問題是即使我明確發送區域值不起作用。如果我嘗試單獨運行每個獨立的gui並單獨驗證,它會正確設置標誌,但是當我將它們一起運行時,它不會正確設置標誌。

回答

0

再看一下在verify功能下面幾行:

c = size(extract); 
for k = 1:c 

我相信你真的想

c = numel(extract); 

因爲size返回向量。

+0

nume1是做什麼用的? – Aps18

+0

'numel'返回數組中元素的個數。請參閱http://www.mathworks.co.uk/help/techdoc/ref/numel.html。 – Nzbuu

+0

「未定義函數或方法 '數字1'輸入參數的類型 '雙'。」我得到這個錯誤,我使用它。 – Aps18