フィルターのクリア

Can I overwrite a function in a compiled program with a custom version?

9 ビュー (過去 30 日間)
Zhangxi Feng
Zhangxi Feng 2019 年 7 月 1 日
コメント済み: Zhangxi Feng 2019 年 7 月 2 日
I have a set of MATLAB functions with a main function that will be compiled. This program calls a function that requires the user to design part of it.
For example, I have a compiled program runFit.exe. The source code calls a wrapper.m that gets some parameters which the user defines how the parameters are actually used. I would need to include wrapper.m when I compile runFit.exe, but can the user write a new wrapper.m that gets used instead of the one compiled in the code? Or is the only way is to not compile the program?
Thanks!
Jesse

採用された回答

Jan
Jan 2019 年 7 月 1 日
This will not work. And if it works, it would conflict with the license conditions.
Do not provide parameters as M-functions, but as data files, e.g. in text format, as binary or MAT file. Then it is easy to let the user change the parameters without the need to parse and run an M-function.
  8 件のコメント
Guillaume
Guillaume 2019 年 7 月 2 日
For example, some times it may need to write more parameters, sometimes less, and sometimes may need to write more than one file.
While allowing user to specify all this as matlab code may be the easiest for now, it's also the most fragile. The user have to be careful not to stomp over your own variables with their m code (maybe they're not even aware of your own variables, and one day a user overwrites one of your variable which slightly changes the behaviour of the code and results in slightly incorrect outputs. That goes unnoticed until the probe crashes into Mars because it's off by a few 100 meters).
The correct way to deal with this is to provide an input method completely independent of m code that allows for all these variations. It could be via configuration, a GUI, whatever. Yes, it'll be more work to start with, but ultimately a better usage experience.
Zhangxi Feng
Zhangxi Feng 2019 年 7 月 2 日
Thank you for your suggestions. I can definitely see a way to design an input file reader that dynamically recognizes the user's desired parameters and writes them according to the user's given conditions to achieve the level of flexibility for this.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMATLAB Compiler についてさらに検索

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by