What is the best way to organize parameters in a flexible way?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Mr M.
am 11 Jun. 2015
Beantwortet: Image Analyst
am 11 Jun. 2015
Interpretation of some parameters depend on other parameters, and I want to store a meaningful name if possible. As an example:
type_of_function = 'linear' or 'sinusoid' if linear: a and b should be the parameters if sinusoid: amplitude, phase, frequency should be the parameters.
So how to organize my parameters? In a structure? Or cell array? And how?
0 Kommentare
Akzeptierte Antwort
Image Analyst
am 11 Jun. 2015
Cell arrays are complicated and confusing. I think a structure or structure array is a lot simpler, intuitive, and more straightforward if you have a mixture of related data of different types. It's a good choice to hold a variety of data.
If all your data have the same number of elements, though they may be of different types, then a table would be good and may have some advantages over a structure for doing certain types of bulk operations.
If you want certain functions to be associated with your data, then you can build a class, but if all you have is just data and just need a way to store them, then you wouldn't need a class.
0 Kommentare
Weitere Antworten (1)
Ingrid
am 11 Jun. 2015
Bearbeitet: Ingrid
am 11 Jun. 2015
I would think in a class so that you write a class functionType which can hold two classes either linear or sinusoid and than define a class for both the linear and the sinusoid which defines which parameters these classes can hold
organizing as a class has an additional advantage that you can also define methods that perform calculations with your parameters
0 Kommentare
Siehe auch
Kategorien
Mehr zu Data Types 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!