Convert simscape model in Windows to Mac

2 次查看(过去 30 天)
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