Parameter exchange between Simscape Custom Block and MATLAB
9 ビュー (過去 30 日間)
古いコメントを表示
I'm quite new to Simulink/Simscape and currently i am working on some custom blocks by using the Simscape language.
Is there any possibility to use parameters and variables from the MATLAb workspace in a custom block in Simulink/Simscape? I can't find a hint in the Simscape language guide. If not, is there a similar function to use these parameters with standard Simulink blocks? Thanks a lot!
2 件のコメント
Hakan
2015 年 7 月 30 日
Hi! You could set up your parameters in the parameter section. Thus you get a nice dialog, where you can input your workspace variables.
Cyril CRIER
2022 年 7 月 7 日
Hello Hakan,
I've the issue right now where I want to use a Base Workspace's Variable in the section "parameter", but this one is not recognized...
parameters
% Add parameters here
Inertia = { TGWeight*(Lever_COG_Close*10^-3)^2, 'kg*m^2' }; % Inertia
AB = {108.4819, "mm"}; % Distance between pivot points on stator
AC = {521.1536, "mm"}; % Distance between pivot points on tailgate
end
TGWeight and Lever_COG_Close are declared through another script first but I get this error window when I browse the file I wanna use for the custom block:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1057615/image.jpeg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1057620/image.jpeg)
Is there a solution?
Thanks
回答 (1 件)
Lincoln Emilio Bowen Aguayo
2015 年 6 月 16 日
You can use variables on SimScape from the script of Matlab, like this:
assignin('base', 'the name of your variable', 'the value');
and if you want to run your program, you can do this:
model = 'The name of your SimScape/Simulink program'; load_system(model); open_system(model);
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Foundation and Custom Domains についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!