Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

Applying all methods of objects in array of objects in random order

3 Ansichten (letzte 30 Tage)
Uwe Ehret
Uwe Ehret am 13 Nov. 2015
Geschlossen: MATLAB Answer Bot am 20 Aug. 2021
Dear All, I have an object containing several arrays of objects. Objects in each array are of the same class. I want to execute all methods of all objects in all arrays exactly once, but in random order. Do you know how to do this in an efficient manner?
Regards, Uwe
  4 Kommentare
Image Analyst
Image Analyst am 13 Nov. 2015
So you have an object, and you say it is "an object containing several arrays of objects". Let's call that object objMain. Now that object has arrays as variables, let's say objArray1, objArray2, and objArray3. But then you say "Objects in each array are of the same class" so I'm assuming each array is really an array of class objects
So let's say you have a class called "myModel" with methods SoilLayers(), RiverStretches(), etc.
So let's say you want to call the "SoilLayers" method of array #2 in your main object, which we'll call objMain. So you'd want to do this:
theOutput1 = objMain.objArray(2).SoilLayers();
And then you want to call
theOutput2 = objMain.objArray(2).RiverStretches();
and other methods in a random order. Is that what you want to do? If not, please refine your terminology to make it more accurate.
Uwe Ehret
Uwe Ehret am 13 Nov. 2015
your description is pretty close: - objMain exists and contains several arrays of class objects: For example, one array 'soillayers' containing 200 instances of a 'SoilLayer' class, and one array 'rivers' containing 100 instances of a 'RiverStretch' class. - The 'SoilLayer' class has two methods, 'Evaporation' and 'Infiltration' - The 'RiverStretch' has two methods, 'Waterflow' and 'Heattransport' - And now I would like to call 'Evaporation' and 'Infiltration' for all 'SoilLayer' instances in 'soillayers', and 'Waterflow' and 'Heattransport' for all 'RiverStretch' instances in 'rivers' in random order. The random aspect is important here, otherwise calling the methods would not be a problem.
Thanks a lot for your help! Uwe

Antworten (0)

Diese Frage ist geschlossen.

Community Treasure Hunt

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

Start Hunting!

Translated by