Hi, help me in this error: unrecognized field name 'categories'.

54 次查看(过去 30 天)
% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
categories=handles.categories;
congMat(1)=handles.congMat(1);
congMat(22)=handles.congMat(22);
congMat(43)=handles.congMat(43);
congMat(64)=handles.congMat(64);
congMat(85)=handles.congMat(85);
congMat(106)=handles.congMat(106);
congMat(127)=handles.congMat(127);
congMat(148)=handles.congMat(148);
congMat(169)=handles.congMat(169);
congMat(190)=handles.congMat(190);
congMat(211)=handles.congMat(211);
congMat(232)=handles.congMat(232);
congMat(253)=handles.congMat(253);
congMat(274)=handles.congMat(274);
congMat(295)=handles.congMat(295);
congMat(316)=handles.congMat(316);
congMat(337)=handles.congMat(337);
congMat(358)=handles.congMat(258);
congMat(379)=handles.congMat(379);
congMat(400)=handles.congMat(400);

回答(1 个)

Ishu
Ishu 2023-8-28
Hi Afiq,
The error message “unrecognized field name ‘categories’” indicates that the field name ‘categories’ does not exist within the handles structure.
Before using ‘categories’ field you need to ensure that the field 'categories' is correctly defined and initialized within the ‘handles’ structure. To ensure this you can follow these steps:
  1. Check if the field ‘categories’ is defined in the initialization function. To check this, you can make use of ‘isfield’ function.
  2. As MATLAB is case sensitive, verify the spelling and case sensitivity of the field name.
  3. Ensure that the code that assigns value to the ‘categories’ field is executed before the line “categories = handles.categories” is reached.
For more information on ‘isfield function you can refer to this documentation:
Hope it helps!

类别

Help CenterFile Exchange 中查找有关 Get Started with MATLAB 的更多信息

产品


版本

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by