How to find an index of an object from object array?
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Nirmal Hirani
am 13 Okt. 2022
Kommentiert: Nirmal Hirani
am 15 Okt. 2022
classdef data
properties (SetAccess = 'public' ,GetAccess = 'public')
Name
end
end
d1 = data();
d2 = data();
d3 = data();
d1.Name = 'data1';
d2.Name = 'data2';
d2.Name = 'data3';
% object array
mylist = [d1 d2 d3]
% asking user to input a name
userInput = 'data2'
% return a index number from 'mylist' based on the name of "userInput"
% ??
I need to check "mylist" and go through objects in that list and check which object has the name == userInput and return the index of that object. In this case return 2
0 Kommentare
Akzeptierte Antwort
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Text Analytics Toolbox finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!