Storing and choosing between sets of parameters
Show older comments
Hello!
I've looked into the issue for over an hour now, and still can't seem to find the correct search terms relating to my (easy) problem. Here goes:
in an engine simulation, I got a model of the actual engine block as well as attached machinery (turbocharger). The engine, as well as the turbocharger, have parameters that they run on, e.g. lengths, volumes etc. In the model, actual real-life parameters are used. For example, a certain engine X has a set of parameters. Between simulations, the engine should be swappable. For example, a drop-down menu offers the choice between the engines, and thus the user can quickly pick engine Y and run the simulation with the set of parameters for engine Y. There is no need for them to be tunable during simulation. Lastly, an option should be incorporated that lets the user input arbitrary parameters into the about 10 fields. The engine and turbocharger components are not related and should be editable independently.
This is currently solved using masks. A popup occurs double-clicking, it does exactly what is described above. However, the engine parameters are hardcoded into the contained callback function; that means that it explicitly says 'Volume V_1 of engine X = 123', 'Volume V_2 of engine Y = 321' and so forth...
Ideally, I'd love to have a centralised GUI where I can edit engines (and turbines etc...) and their parameters, and add new ones, and have a great overview. I imagine something similar to the Data Dictionary, which I use for global data. Then, the engine can have a mask with a simple drop-down menu of options, fetching data from somewhere else (so that there's no data in the mask itself). Currently, in order to add a new alternative for an engine, you'd actually have to dig into the mask and add the data there. It is also fragmented, meaning that e.g. the intake manifold is a model separate to the engine itself, but its volume is of course changing (in real-life at least) by changing the engine; right now, you'd have to edit the two masks separately.
I've finally stumbled upon Variants of subsystems, but they seem to be about altering actual methods (like switching between different controllers); in my case, the calculations ought to be the same, just the very simple parameters change. That is why I'm uncertain whether Variants are the correct solution here.
With a Structure, it seems like I'd have to retype the parameter names each time? It doesn't seem to be the most elegant or robust way.
A lookup table was advised against by a more experienced user helping me (I honestly don't know what that is anyway).
So, a lot of text from a newbie. I imagine the solution is super simple..
Thanks a lot!
Accepted Answer
More Answers (0)
Categories
Find more on Programmatic Model Editing in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!