Accessing network drives from within Matlab

I have two Windows 10 computers running Matlab 2023b on the same network. On one computer, I am able to reach a remote network drive easily enough from the Matlab prompt,
>> cd '\\drivepathname'
However, on the other computer, while I can access the network drive through Windows File Explorer, I cannot do so from within Matlab,
>> cd '\\drivepathname'
Error using cd
Unable to change current folder to '\\drivepathname' (Folder access failure).
I am trying to guess what might be different about the 2 installations. Ay suggestions are welcome.
EDIT: If it matters, the computer which is throwing the error is accessing the network via a VPN.

5 个评论

We ran into something similar as far as end-user symptoms on the college network that turned out to be that two machines sitting side-by-side in the same office were connected to the network via two separate routers that couldn't see each other.
IOW, it may have little or nothing to do with the MATLAB install itself, but the network configuration itself or the firewall settings.
But if firewall settings were blocking Matlab, why wouldn't it also block Windows Explorer?
As an additional data point, I am not encountering the issue in R2023a.
May be it is a problem with access rights? Try to start matlab as admin.
So I have now discovered the problem occurs only when running as admin. I don't know what that might indicate.

请先登录,再进行评论。

回答(1 个)

Assuming the SMB port is open on the system with the shared folder and a VPN is being used to access these folders, here are two common methods to consider:
1. Map Network Drive: Map the address of the network shared folder to a drive letter on the PC, such as Z:. Then, use the following MATLAB code:
cd("Z:")
You can learn more about mapping a network drive here:
2. Use the IP Address: Access the shared folder using its IP address. For example, to access the shared directory, use the following MATLAB code:
cd("\\IP_ADDRESS\Path\To\Folder") % Example: cd("172.0.0.2\Users")
I hope this helps you.

3 个评论

Thanks, @Swastik Sarkar, but 1 isn't working,
>> cd G:\
Error using cd
Unable to change current folder to 'G:\' (Name is nonexistent or not a folder).
and 2 requires data (the IP address) which I do notknow how to get. I wonder if this is really necessary in any case, since
>> cd '\\drivepathname'
works fine on the first machine.
Check UAC settings on the two machines..
From some reason, the Example did not get formatted correctly, please try the below line of code:
cd("\\172.0.0.2\Users") % Replace IP Address and Folder Path

请先登录,再进行评论。

类别

帮助中心File Exchange 中查找有关 Startup and Shutdown 的更多信息

产品

版本

R2023b

提问:

2024-9-10

评论:

2024-11-15

Community Treasure Hunt

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

Start Hunting!

Translated by