Convert simscape model in Windows to Mac

2 Ansichten (letzte 30 Tage)
Chris Verhoek
Chris Verhoek am 26 Jan. 2021
Bearbeitet: Chris Verhoek am 26 Jan. 2021
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!

Akzeptierte Antwort

Chris Verhoek
Chris Verhoek am 26 Jan. 2021
Bearbeitet: Chris Verhoek am 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

Weitere Antworten (0)

Kategorien

Mehr zu Troubleshooting finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by