When I run very simple code, octave returns that the Folder does not exist, but I'm pretty sure it exists. I can't grasp what I'm doing wrong.
function TestLoading(path)
if isfolder(path)
disp('Folder exists');
else
disp('Folder does not exist');
end
end
folder_path = "C:/A";
TestLoading(folder_path);
I can't get it to find any folder. I can load some files from that directory, just isfolder not working.
What is you filename? In Octave and Matlab name of .m
files matter.
I changed your code and added a simple disp
command to it:
function TestLoading(path)
if isfolder(path)
disp('Folder exists');
else
disp('Folder does not exist');
end
end
disp('Hello World');
folder_path = pwd();
TestLoading(folder_path);
By running octave TestLoading.m
, you can be sure the Hello World
won't be printed. Since Octave runs your TestLoading
function, not its caller code (and all codes after it). So It will run with empty path
argument and displays Folder does not exist
.
I edited your code and saved in MyFunc.m
file:
function MyFunc()
folder_path = pwd();
TestLoading(folder_path);
end
function TestLoading(path)
if isfolder(path)
disp('Folder exists');
else
disp('Folder does not exist');
end
end
And running it:
[gmt@arch ~]$ octave MyFunc.m
Folder exists