将 MATLAB 文件转换为 Octave

发布于 2024-12-01 08:22:18 字数 2556 浏览 0 评论 0原文

我有一系列为 MATLAB 编写的实验,但最近我们尝试通过 Octave 来运行它们。我意识到它们大多是兼容的,但我遇到了一些问题,而且我发现的在线常见问题解答或说明都没有解决这些问题。这有点复杂,因为有多个 .m 文件相互作用;不过,现在我将重点关注主程序。无论如何,所以当我尝试通过八度运行文件(MLP.m)时,我在终端窗口中收到以下错误:

error: dir: expecting directory or filename to be a char array
error: called from:
error: /Applications/Octave.app/Contents/Resources/share/octave/3.2.3/m/miscellaneous/dir.m at line 128, column 5
error: /Applications/MATLAB_R2008a/toolbox/psychoacoustics/MLParameters.m at line 86, column 7
error: /Applications/MATLAB_R2008a/toolbox/psychoacoustics/MLP.m at line 9, column 3

它引用的行如下:

1)

d = dir([cd myslash 'Experiments_MLP'  myslash '*.m']);

2)

s = MLParameters; 

这些行与八度不兼容怎么办?我在网上找不到任何表明这些不起作用的信息。

之后,终端窗口给了我这批废话:

dyld: Library not loaded: /usr/X11/lib/libfreetype.6.dylib
  Referenced from: /usr/X11R6/lib/libfontconfig.1.dylib
  Reason: Incompatible library version: libfontconfig.1.dylib requires version 13.0.0 or later, but libfreetype.6.dylib provides version 10.0.0
dyld: Library not loaded: /usr/X11/lib/libfreetype.6.dylib
  Referenced from: /usr/X11R6/lib/libfontconfig.1.dylib
  Reason: Incompatible library version: libfontconfig.1.dylib requires version 13.0.0 or later, but libfreetype.6.dylib provides version 10.0.0
/Applications/Gnuplot.app/Contents/Resources/bin/gnuplot: line 71:  1077 Trace/BPT trap          GNUTERM="${GNUTERM}" GNUPLOT_HOME="${GNUPLOT_HOME}" PATH="${PATH}"     DYLD_LIBRARY_PATH="${DYLD_LIBRARY_PATH}" HOME="${HOME}" GNUHELP="${GNUHELP}" DYLD_FRAMEWORK_PATH="${DYLD_FRAMEWORK_PATH}" GNUPLOT_PS_DIR="${GNUPLOT_PS_DIR}" DISPLAY="${DISPLAY}" GNUPLOT_DRIVER_DIR="${GNUPLOT_DRIVER_DIR}" "${ROOT}/bin/gnuplot-4.2.6" "$@"
/Applications/Gnuplot.app/Contents/Resources/bin/gnuplot: line 71:  1083 Trace/BPT trap          GNUTERM="${GNUTERM}" GNUPLOT_HOME="${GNUPLOT_HOME}" PATH="${PATH}" DYLD_LIBRARY_PATH="${DYLD_LIBRARY_PATH}" HOME="${HOME}" GNUHELP="${GNUHELP}" DYLD_FRAMEWORK_PATH="${DYLD_FRAMEWORK_PATH}" GNUPLOT_PS_DIR="${GNUPLOT_PS_DIR}" DISPLAY="${DISPLAY}" GNUPLOT_DRIVER_DIR="${GNUPLOT_DRIVER_DIR}" "${ROOT}/bin/gnuplot-4.2.6" "$@"
error: you must have gnuplot installed to display graphics; if you have gnuplot installed in a non-standard location, see the 'gnuplot_binary' function

我安装了 GNUPlot,并且检查了 gnuplot_binary 函数,它没有给我任何答案。 GNUPlot 与 Octave 本身一起安装在我的 /Applications 目录中。为什么这不起作用? GNUPlot 附带的 README 文件没有指明安装的特殊目录。dyld 库未加载错误怎么办?这与 GNUPlot 问题有关,还是其他问题?

不管怎样,谢谢你的帮助

I have a series of experiments that were written for MATLAB, but recently we are trying to run them through Octave instead. I realize they are mostly compatible, but I have been running into a few problems, and none of the online FAQs or directions I have found have addressed these at all. It's complicated a bit because there are multiple .m files that interact; however, for now I am going to focus on the main program. Anyway, so when I try to run the file (MLP.m) through octave, I get the following errors in the Terminal window:

error: dir: expecting directory or filename to be a char array
error: called from:
error: /Applications/Octave.app/Contents/Resources/share/octave/3.2.3/m/miscellaneous/dir.m at line 128, column 5
error: /Applications/MATLAB_R2008a/toolbox/psychoacoustics/MLParameters.m at line 86, column 7
error: /Applications/MATLAB_R2008a/toolbox/psychoacoustics/MLP.m at line 9, column 3

The lines it is referencing are as follows:

1)

d = dir([cd myslash 'Experiments_MLP'  myslash '*.m']);

2)

s = MLParameters; 

What about these lines is incompatible with Octave? I can't find anything online that indicates that these won't work.

After that, the Terminal window gives me this batch of nonsense:

dyld: Library not loaded: /usr/X11/lib/libfreetype.6.dylib
  Referenced from: /usr/X11R6/lib/libfontconfig.1.dylib
  Reason: Incompatible library version: libfontconfig.1.dylib requires version 13.0.0 or later, but libfreetype.6.dylib provides version 10.0.0
dyld: Library not loaded: /usr/X11/lib/libfreetype.6.dylib
  Referenced from: /usr/X11R6/lib/libfontconfig.1.dylib
  Reason: Incompatible library version: libfontconfig.1.dylib requires version 13.0.0 or later, but libfreetype.6.dylib provides version 10.0.0
/Applications/Gnuplot.app/Contents/Resources/bin/gnuplot: line 71:  1077 Trace/BPT trap          GNUTERM="${GNUTERM}" GNUPLOT_HOME="${GNUPLOT_HOME}" PATH="${PATH}"     DYLD_LIBRARY_PATH="${DYLD_LIBRARY_PATH}" HOME="${HOME}" GNUHELP="${GNUHELP}" DYLD_FRAMEWORK_PATH="${DYLD_FRAMEWORK_PATH}" GNUPLOT_PS_DIR="${GNUPLOT_PS_DIR}" DISPLAY="${DISPLAY}" GNUPLOT_DRIVER_DIR="${GNUPLOT_DRIVER_DIR}" "${ROOT}/bin/gnuplot-4.2.6" "$@"
/Applications/Gnuplot.app/Contents/Resources/bin/gnuplot: line 71:  1083 Trace/BPT trap          GNUTERM="${GNUTERM}" GNUPLOT_HOME="${GNUPLOT_HOME}" PATH="${PATH}" DYLD_LIBRARY_PATH="${DYLD_LIBRARY_PATH}" HOME="${HOME}" GNUHELP="${GNUHELP}" DYLD_FRAMEWORK_PATH="${DYLD_FRAMEWORK_PATH}" GNUPLOT_PS_DIR="${GNUPLOT_PS_DIR}" DISPLAY="${DISPLAY}" GNUPLOT_DRIVER_DIR="${GNUPLOT_DRIVER_DIR}" "${ROOT}/bin/gnuplot-4.2.6" "$@"
error: you must have gnuplot installed to display graphics; if you have gnuplot installed in a non-standard location, see the 'gnuplot_binary' function

I have GNUPlot installed, and I checked the gnuplot_binary function, which didn't give me any answers. GNUPlot is installed in my /Applications directory, along with Octave itself. Why shouldn't this work? The README file that came with GNUPlot didn't indicate a special directory for it to be installed in. What about the the dyld library not loaded errors? Is that related to the GNUPlot problem, or is it something else?

Anyway, thanks for your help

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

陪你到最终 2024-12-08 08:22:18

我知道您已经解决了问题,但如果您再次遇到问题,这里有一些链接,其中包含有关 Matlab 和 Octave 之间差异的基本信息:

I know you already solved your problem, but if you have problems again here are some links with basic information about the differences between Matlab and Octave:

故人的歌 2024-12-08 08:22:18

解决你的第一个错误,用一个例子更容易解释:

dirName = '/some/path';                       %# base directory
filesPath = fullfile(dirName, 'MLP', '*.m');  %# full path string

d = dir(filesPath);                           %# expand/enumerate files
for i=1:numel(d)
    disp( d(i).name )
end

你也可以自己使用字符串连接构建路径:

%# '/some/path/MLP/*.m'
filesPath = [dirName filesep 'MLP' filesep '*.m'];

上面的内容应该适用于 MATLAB 和 Octave

Addressing your first error, it's easier to explain with an example:

dirName = '/some/path';                       %# base directory
filesPath = fullfile(dirName, 'MLP', '*.m');  %# full path string

d = dir(filesPath);                           %# expand/enumerate files
for i=1:numel(d)
    disp( d(i).name )
end

You also could have built the path using string concatenation yourself:

%# '/some/path/MLP/*.m'
filesPath = [dirName filesep 'MLP' filesep '*.m'];

The above should work for both MATLAB and Octave

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文