Error using cd Cannot CD to ...(Name is nonexistent or not a directory).
Show older comments
I have a script to load a file. It works well on another computer but on my laptop it gives me an error of: Error using cd Cannot CD to ... (Name is nonexistent or not adirectory).
The script is: pathname = '/LENOVO/Neolab/P5_260418/10sIllumination';
filelocation = fullfile(pathname,'*.swt');
files = dir(filelocation); cd(pathname);
data = zeros(4096,32,4,length(files));
for i = 1:length(files)
[data(:,:,:,i),timestamp(i),ill_number(i),cycle(i),source(i),t] = SWTread_RJC_LAD(files(i).name);
end
[SortedIllum, SortedIndex] = sort(ill_number);
%Resort the variables data = data(:,:,:,SortedIndex); cycle = cycle(SortedIndex); ill_number = ill_number(SortedIndex); source = source(SortedIndex); timestamp = timestamp(SortedIndex);
Is there any solution?
1 Comment
Stephen23
on 8 May 2018
"Name is nonexistent or not a directory"
Seems quite clear to me: you need to pass cd a path that actually exists.
Even better would be to avoid slow cd entirely, by passing absolute/relative filenames:
Answers (1)
Get rid of the cd entirely:
D = '/LENOVO/Neolab/P5_260418/10sIllumination';
S = dir(fullfile(D,'*.swt'));
N = numel(S)
Z = zeros(4096,32,4,S);
for k = 1:N
F = fullfile(D,S(k).name);
[Z(:,:,:,k),timestamp(k),ill_number(k),cycle(k),source(k),t] = WTread_RJC_LAD(F);
end
Categories
Find more on Performance and Memory 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!