Convert simscape model in Windows to Mac

2 ビュー (過去 30 日間)
Chris Verhoek
Chris Verhoek 2021 年 1 月 26 日
編集済み: Chris Verhoek 2021 年 1 月 26 日
I'm working together with someone that involves a SimScape model of a system. The thing is that he is using windows, and I'm using Mac. So now is the problem that all the paths in the simulink/simscape model for Windows have the path towards the stepfile of the form: "system\part1.step". This causes an error on my mac, because it is looking for "system/part1.step".
Is there a way to quickly/automatically change this in the model? Because a lot of parts and a lot of versions imply a lot of work!

採用された回答

Chris Verhoek
Chris Verhoek 2021 年 1 月 26 日
編集済み: Chris Verhoek 2021 年 1 月 26 日
It is quite easy, actually. The parameter name is of the simulink block is "ExtGeomFileName"
load_model('simulinkmodel1')
% ....
% Only for Mac users
if ismac
% Find all the blocks in the simscape model
blocks_in_model = find_system('simulinkmodel1/system', 'LookUnderMasks','all');
% Check for all the blocks if there exists a parameter with this filepath
for ii = 1:length(blocks_in_model)
try % if this param exists, replace the slash.
filepath = get_param(blocks_in_model{ii},'ExtGeomFileName');
macpath = strrep(filepath,'\','/');
set_param(blocks_in_model{ii},'ExtGeomFileName',macpath);
catch % No such param
end %endtrycatch
end %endfor
end %endif
Easy peazy quick-fix-squeezy

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by