Borrar filtros
Borrar filtros

folder path difference in 'Windows' and 'Linux' system

32 visualizaciones (últimos 30 días)
Yu Li
Yu Li el 13 de En. de 2019
Comentada: Yu Li el 14 de En. de 2019
I found that the folder path expression is different between 'windows' and 'linux' system.
for window system, it use '\' between folders and sub-folders,
in linux system, it uses '/'.
this make some error when I translate the matlab code from windows to linux system.
is this an inherent feature of Matlab? or is there anyway to solve this problem?
Thansk!
Yu

Respuesta aceptada

Rik
Rik el 13 de En. de 2019
This is not an inherent feature of Matlab, but of the operating system that runs Matlab.
You can avoid this problem by not hardcoding your folder paths, and if you do, use fullfile and/or filesep.
  5 comentarios
Stephen23
Stephen23 el 14 de En. de 2019
"I have code such as tmp=[pwd,'\test.mat'], but when I translate these code into Linux it reports error"
This is exactly why you should avoid hard-coding file separators and avoid using string concatenation. It is much better to use fullfile, which automatically takes care of this.
This difference in separators has nothing to do with MATLAB, it is determined by the OS. Other OSs use other file separators too:
Yu Li
Yu Li el 14 de En. de 2019
Thank you all!
Bests,
Yu

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Search Path en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by