Is it possible to change the unit of reluctance block of MATLAB from m.file?

3 views (last 30 days)
I am using a number of reluctance blocks for simulation and the values of the of that block are from workspace using the m.file. However, is there any way to change the unit as well? For example, the reluctance block requires values of length and area. The values are provided as 1m and 1m^2. I would like to change the length from 1m to 1cm. One way is the changing value 1 to 0.01 and keeping the unit to m. But I would like to keep the value as 1 and change the unit from m to cm. As the number of blocks are more, is there way to chnage the unit from the m.file? If so, how can I do that?

Answers (1)

Paul
Paul on 22 May 2023
Edited: Paul on 22 May 2023
It appears this can be done via typical set_param commands. For example, I have a Reluctance block selected in my model:
set_param(gcb,'CSA_unit','cm^2') % change the unit of cross-sectional area to cm^2
To see all parameters for the block
get_param(gch,'ObjectParameters')
There may also be other ways to achieve this goal. Check out Physical Units in the Simscape documentation for more dicussion.

Categories

Find more on Modeling in Help Center and File Exchange

Products


Release

R2022a

Community Treasure Hunt

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

Start Hunting!