Undefined function or variable

4 Ansichten (letzte 30 Tage)
Shahmeer Rosli
Shahmeer Rosli am 16 Mai 2016
Kommentiert: Shahmeer Rosli am 16 Mai 2016
% --- Executes on button press in pushbutton4.
function pushbutton4_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global YYY bbox
getappdata(0,'bbox');
Yunus1=('Car')
Yunus2=('Bus')
Yunus3=('Motor')
Yunus4=('Truck')
Yunus5=('Unknown')
total = bwarea(bbox);
Z=total;
load ('car_1.mat');
load ('bus_1.mat');
load ('motor_1.mat');
load ('truck_1.mat');
if any(Z==car_1);
set(handles.edit_2,'String',Yunus1);
elseif any (Z== bus);
set(handles.edit_2,'String',Yunus2);
elseif any (Z== motor);
set(handles.edit_2,'String',Yunus3);
elseif any (Z== truck);
set(handles.edit_2,'String',Yunus4);
else
set(handles.edit_2,'String',Yunus5);
end
Error
Undefined function or variable 'car_1'.
Error in test_gui>pushbutton4_Callback (line 209)
if any(Z==car_1);
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in test_gui (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in @(hObject,eventdata)test_gui('pushbutton4_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback

Antworten (1)

Walter Roberson
Walter Roberson am 16 Mai 2016
You would get that error if none of your .mat files defines a variable named car_1 . Remember, when you load a .mat file in that form of load, the variables that appear in the workspace are named the same thing as the variables in your .mat file, which might not be the same thing as the name of the .mat file.
You are doing equality comparisons between the computed area and some loaded values. Those will almost never be exactly equal. http://matlab.wikia.com/wiki/FAQ#Why_is_0.3_-_0.2_-_0.1_.28or_similar.29_not_equal_to_zero.3F
You should be considering checking to see which of the values is closest to the computed area.
  1 Kommentar
Shahmeer Rosli
Shahmeer Rosli am 16 Mai 2016
Tq for helping my coding on database not same. Its already done.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Migrate GUIDE Apps finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by