我最近安装了 oct2py 及其依赖项,以便导入一些要在我的 python 代码中使用的 matlab 函数。.m 文件与我的 python 代码位于同一目录中。
考虑到实际函数是在 octave/matlab 中定义的,您能否帮我弄清楚我将如何导入这些 .m 文件以及其中的方法以及如何在我的 python 代码中使用这些函数。我已经包含了一个带有函数的示例 .m 文件
function x=readfile(y)
% Puts the contents of a text file with path and name
% specified in string y, into char array x.
% Example: mystring = readfile('c:\workdir\readme.txt');
fid = fopen(y,'r'); % Read the Plaintext
M = fread(fid);
fclose(fid);
x = char(M');
上述函数位于与我的 python 代码相同的目录中名为“readfile.m”的文件中。