Octave 找不到任何文件夹

问题描述 投票:0回答:1

当我运行非常简单的代码时,八度返回该文件夹不存在,但我很确定它存在,因为它是一个工作目录。 我无法理解我做错了什么。

function TestLoading(path)
    if isfolder(path)
        disp('Folder exists');
    else
        disp('Folder does not exist');
    end
end
folder_path = pwd();
TestLoading(folder_path);

我无法让它找到任何文件夹,所以我尝试了 pwd 只是为了确定。

octave pwd
1个回答
0
投票

你的文件名是什么?在 Octave 和 Matlab 中,

.m
文件的名称很重要。

我编辑了你的代码并保存在

MyFunc.m
文件中:

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

并运行它:

[gmt@arch ~]$ octave MyFunc.m 
Folder exists
© www.soinside.com 2019 - 2024. All rights reserved.