Azzera filtri
Azzera filtri

File searching changes current folder

1 visualizzazione (ultimi 30 giorni)
Ignacio
Ignacio il 24 Mar 2014
Commentato: Ignacio il 24 Mar 2014
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.

Risposte (1)

Walter Roberson
Walter Roberson il 24 Mar 2014
Yes, run() does change directory.
  1 Commento
Ignacio
Ignacio il 24 Mar 2014
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.

Accedi per commentare.

Categorie

Scopri di più su Programming in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by