将MATLAB文件转换为Octave [英] Converting MATLAB files to Octave

查看:166
本文介绍了将MATLAB文件转换为Octave的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一系列针对MATLAB编写的实验,但是最近我们正尝试通过Octave运行它们.我知道它们基本兼容,但是我遇到了一些问题,而且我发现的所有在线常见问题解答或说明都没有解决这些问题.这有点复杂,因为存在多个交互的.m文件.但是,现在我将专注于主程序.无论如何,因此当我尝试通过八度运行文件(MLP.m)时,在终端"窗口中出现以下错误:

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

它所引用的行如下:

1)

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

2)

s = MLParameters; 

这些行与Octave不兼容吗?我在网上找不到任何东西表明这些东西行不通.

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

我已经安装了GNUPlot,并且检查了gnuplot_binary函数,该函数没有给出任何答案. GNUPlot和Octave本身一起安装在我的/Applications目录中.为什么不行呢? GNUPlot随附的README文件未指示要安装的特殊目录.dyld库未加载错误怎么办?这与GNUPlot问题有关还是其他问题?

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

推荐答案

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

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'];

以上内容适用于MATLAB和Octave

The above should work for both MATLAB and Octave

这篇关于将MATLAB文件转换为Octave的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆