Is there a way to perform queries on object collections?
Ältere Kommentare anzeigen
Hi, I know I can use arrayfun to call a method on each object in an array, but is there a way to perform queries across the array?
This is a made up example, but if I have a class
MATLAB code
classdef Employee
properties
salary = 0; %Set later
end
And I have an array of instances of this class
MATLAB code
staff = [employee1 employee2 employee3 ..... employeeN];
Is there an easy way I can write a query to get, say, the 3 Employees with the largest salarys?
Thanks for any help, just give me a shout if this isn't clear.
Tom.
Akzeptierte Antwort
Weitere Antworten (1)
Sean de Wolski
am 16 Dez. 2011
0 Stimmen
Instead of having each employee be its own variable ( like this ) have an employer class with employees as properties and salaries as properties.
There are many example available from the documentation for classdef.
1 Kommentar
tombola
am 16 Dez. 2011
Kategorien
Mehr zu Shifting and Sorting Matrices finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!