defining the constant mentioned in the parameter's value

1 回表示 (過去 30 日間)
Yun-Chi Yang
Yun-Chi Yang 2022 年 4 月 8 日
コメント済み: David John 2022 年 4 月 19 日
When I am reading the examples from MathWork, I opened see parameter like the picture:
ex. pi*tube_diameter^2/4
"pi" is 3.14159... we know it, but "tube_diameter", is this a constant defined somewhere?
Can someone tell me where can I found the value of "tube_diameter", and all these sort of constant?

回答 (1 件)

David John
David John 2022 年 4 月 11 日
This parameter gets loaded into the MATLAB workspace when you open the example model. If you go to MATLAB and look at the variables there, you should see it. It gets deleted when you close the model.
You can also see where this parameter is loaded into the base workspace by opening "Model Settings" --> "Model Properties" --> "Callbacks" --> "PreLoadFcn" although you can also just change the value in MATLAB once the model has been opened.
  3 件のコメント
Yun-Chi Yang
Yun-Chi Yang 2022 年 4 月 13 日
What should we do if we want to create parameter like this in our own model? Where do we "preload" it and specify the value? And how can we make any changes if we want?
David John
David John 2022 年 4 月 19 日
Yes, you can make changes to the PreLoadFcn if you want, but you will have to save your own local copy of the model as you won't be able to overwrite the example itself. Note that the PreLoadFcn gets called when you are about to open the model, so if you want to just change the parameter while the model is already open, you can just change it by typing something like "tube_diameter = 5" at the MATLAB command prompt.
If you want to do something similar in your own models, you can just create your own model callbacks: Model Callbacks - MATLAB & Simulink (mathworks.com). You can change these however you would like.

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

カテゴリ

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

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by