필터 지우기
필터 지우기

File searching changes current folder

조회 수: 1 (최근 30일)
Ignacio
Ignacio 2014년 3월 24일
댓글: Ignacio 2014년 3월 24일
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.

답변 (1개)

Walter Roberson
Walter Roberson 2014년 3월 24일
Yes, run() does change directory.
  댓글 수: 1
Ignacio
Ignacio 2014년 3월 24일
the problem seems to be that it does not actually add the path of the file, although I wrote addpath(....). If I run the file separately, it asks me if I want to change folder or add to path, although this script already added the folders to the path (they don't appear transparent anymore in the current folder window). This may be a bug, but I don't really know how to completely add the folders to the path if the addpath command does not do anything but changing the transparency of the folders in the current folder.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by