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 CenterFile Exchange에서 Troubleshooting에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by