Problems after upgrading from MATLAB R2013a to MATLAB R2015a - exist gives back '7' for non-existing folder
Show older comments
Eversince I upgraded to MATLAB R2015a I keep getting problems with my older code. I run the same code on identical data, but I get different results (without getting back errors). In this case I am running a little script in which I'm checking which the latest version folder is available to append to my path:
cd(PathBeforeVersion);
Verfind3 = 'Versionv3.0';
Verfind2 = 'Versionv2.0';
if isequal(exist(Verfind3, 'dir'),7) % 7 = folder.
Verfolder = Verfind3 ;
elseif isequal(exist(Verfind2, 'dir'),7) % 7 = folder.
Verfolder = Verfind2 ;
else
display('no Version folder!');
end
PathAfterVersion = fullfile(PathBeforeVersion,Verfolder);
cd(PathAfterVersion);
So what happens is that even though the 'Versionv3.0' folder doesn't exist ('Versionv2.0' exists), the 'exist' gives back 7, thus making Verfolder = Verfind3 and then the path is wrong and cannot cd. I ran for non-existent 'Versionv4.0' and correctly got back a zero from exist. I literally have the folder of the current dir before my eyes, type 'dir' and no such folder exists. Does anyone have any idea what could be happening? Could it be that the 'exist' doesn't just check in my current directory? Is there some setting I could have wrong? (This code worked perfectly on MATLAB R2013a).
Apologies if it is something obvious, but I have run out of ideas.
Thanks in advance.
Accepted Answer
More Answers (1)
Walter Roberson
on 14 Dec 2015
Edited: Walter Roberson
on 14 Dec 2015
0 votes
exist() does search the search path for folders; or at least it does so in R2014a.
Remember, you can ask about ./Versionv3.0 if you want to look only in the current folder.
1 Comment
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!