How do I use matlab on two computers and load files (located in different file locations) in my script?

15 visualizaciones (últimos 30 días)
I plan to use matlab in my school's computer lab. At home, I'll use Matlab on my own computer. I use dropbox to store and access my files from different computers. Sometimes I need to load a file into my matlab script. My problem is: if I use both the school's and my own computer, my files will be in two different file locations; I will need to change the matlab code each time I work at school and at home. What can I do? Thanks.
P.S. I could bring my laptop to school and do all my matlab assignments on my laptop. I'd rather not, because my laptop is heavy and might get stolen or damaged during my science labs.

Respuestas (2)

Daniel Shub
Daniel Shub el 5 de Sept. de 2014
There are lots of ways to tackle this problem. From the OS level, if you are not using Windows, you can create mount points and symbolic links so that the files are in the same place. From within MATLAB you could switch the file location based on the hostname:
switch upper(char(java.net.InetAddress.getLocalHost.getHostName))
case 'MYLAPTOPNAME'
disp('Likely my laptop');
dropBoxLocation = '/home/myname/work';
case 'MYDESKTOPNAME'
disp('Likely my desktop');
dropBoxLocation = '/home/myname/stuff';
otherwise
disp('Some unknown computer');
dropBoxLocation = '/home/myunilogin/';
end
You could of course switch off of ip address, mac address, MATLAB license, or anything else that varies with the machines.

Jason
Jason el 10 de Sept. de 2014
Thanks

Categorías

Más información sobre Introduction to Installation and Licensing en Help Center y File Exchange.

Etiquetas

Aún no se han introducido etiquetas.

Community Treasure Hunt

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

Start Hunting!

Translated by