Is there a path in the string?

2 次查看(过去 30 天)
Luca Re
Luca Re 2023-6-16
hi,
a: example: f='\report\
b: example =f='c:\root\report\
how can i identify the string with case "a" or with "b"?
in the case 'a' i see a folder..
in case 'b' i see a path with folder
  5 个评论
Mathieu NOE
Mathieu NOE 2023-6-20
why something simple could not be used ?

请先登录,再进行评论。

回答(1 个)

Fangjun Jiang
Fangjun Jiang 2023-6-16
You can utilize the exist() function.
Assume you are at the c:\root folder, and there is a \report sub-folder
exist('\report','dir') will return 0
exist('c:\root\report','dir') will return 7, since 'c:\root\report' is the full path of a folder.
Please note, exist('report','dir') will also return 7.

类别

Help CenterFile Exchange 中查找有关 Search Path 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by