Convert simscape model in Windows to Mac

2 views (last 30 days)
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!

Accepted Answer

Chris Verhoek
Chris Verhoek on 26 Jan 2021
Edited: Chris Verhoek on 26 Jan 2021
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

More Answers (0)

Community Treasure Hunt

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

Start Hunting!