Save a file to the first folder in mathpath (the MATLAB-folder)
13 views (last 30 days)
Show older comments
I want to save a variabel to a file and now I use the command: "save filename.mat variabel", but my problem is that I want to save this mat-file in the MATLAB-folder cause if I do so MATLAB can find it directly when you use: "load filename". I know, I can use cd(path) there "path" is the adress to the specific folder I want to save it in, but I want this to work not only for my computer and the adress to this MATLAB-folder is different on different computers and I don't want to change anything when I switch computer. The MATLAB-folder I want to save the file to I think it's always number one in "matlabpath" - the list of the folders that MATLAB is searching for files in. Can I use this information somehow? I want to get the first folder in this list and write cd(number1inthelist). I tried to write mathpath(1) but it didn't work.
Is it someone out there that can help me?
0 Comments
Accepted Answer
KSSV
on 16 Jun 2016
If your interest is to call the saved matfile without mentioning it's path: you have to create a folder and save every file you want in that..and set the path to this folder. You can use this file without mentioning its path. doc 'pathtool'
0 Comments
More Answers (0)
See Also
Categories
Find more on File Operations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!