To organize my software better I'm starting to port my matlab functions to matlab classes and I'm struggling a bit with the oop concept.
Thats the situation:
Here is my first class diagram attached: classDiagram
My main objective is where to put the "loadDataFromX" and "calibrateSensor" methods. If I consider a sensor object representating a "real" sensor, then the sensor can not load data or calibrate itself. It's only possible via a function in the "SensorToolbox". But the calibration realization is different for each sensor. So putting the function into the toolbox would require the detection of the class type and a implementation outside the sensor. The same applies to the sensor's data. Calling "loadDataFromFile" from the toolbox would require to know the needed dataformat outside of the sensor.
Hopefully you understand my problem and you can push me into the right direction, thank you!
I think you should put these methods into sensors. Don't worry that they don't 100% represent the behavior of the real sensor, it is just a model.
Another option is to share these methods between SensorToolbox and Sensor. For example, SensorToolbox can read the data from different datasources and then pass in to the Sensor, for example (pseudocode):
SensorToolbox::loadDataFromDatabase():
database = Database()
data = database->readData()
sensor->loadData(data)
SensorToolbox::loadDataFromFile():
file = File('path/to/file')
data = file->read()
sensor->loadData(data)
Same for the calibration, SensorToolbox can have this method and then just path it to the Sensor (or maybe do some preparation before it):
SensorToolbox::calibrate(Sensor sensor, SensorData data):
// check the data
// ...
sensor->calibrate(data)