File searching changes current folder
2 次查看(过去 30 天)
显示 更早的评论
I have the following program with a lot of files:
clear all
clc
close all
cd('(....here the directory...)/Desktop/Case Studies end')
addpath('(....here the directory...)/Desktop/Case Studies end/DataPlots')
%Here there are some other path files
run('NormalData/RunAllData.m');
%etc.
NormalData/RunAllData opens another files within the folder NormalData and one of them is variables.m, which, when ran, saves the workspace in a .mat file with the command
save NormalData/var.mat;
Nevertheless, it does not work when I run it in the main file which runs all data files. When I run it separately going to the file and running it, it works, but then I have to do this for all the 30 folders I have for every update I make.
The error is the following:
Error using save
Cannot create 'var.mat' because
'NormalData' does not exist.
Error in variables (line 19)
save NormalData/var.mat;
My guess is that when it runs the script NormalData/RunAllData.m, it actually changes the current folder there and therefore it does not find the directory NormalData.
0 个评论
回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Search Path 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!