MATLAB: Does ‘filesep’ not work with ‘gcb’

filesepgcblibraryMATLABsimulinkunixwindows

Hi,
today a problem occurred, I thought it's kind of a no-brainer, but I was wrong:
If I get the pathname of my current simulink block, I get the following
>> gcb
ans = Mechanics/Spring and Damping Elements/mech_sprdam_2mass
But I can't separate the path. If I ask for my file separator, I get
>> filesep
ans = \
Why is my file separator windows-like, but my given path is in unix style? Is there a way to write my script working on both systems?

Best Answer

When you are writing MATLAB scripts to get or set block names or paths, use forward slashes as forward-slashes are always used as the separators for block names/paths regardless of the platform.