【问题标题】:Running on 32 or 64 bit matlab?在 32 位或 64 位 matlab 上运行?
【发布时间】:2010-09-16 20:22:01
【问题描述】:

如何确定我是在 32 位还是 64 位版本的 matlab 上运行?

我有一些预编译的 mex 文件,它们需要不同的路径,具体取决于 32/64 位 matlab。

【问题讨论】:

  • 所以提示:将此作为您自己问题的答案发布,您可能会获得徽章。
  • SO 提示,第 2 部分:并接受答案,以便其他人知道它有一个可靠的解决方案。

标签: matlab 64-bit 32-bit


【解决方案1】:

32 位与 64 位的问题确实是一个红鲱鱼。如果我理解正确,您想确定需要哪组已编译的 MEX 文件,以便您可以适当地设置路径。为此,您可以使用函数mexext

>> help mexext
 MEXEXT MEX filename extension for this platform, or all platforms. 
    EXT = MEXEXT returns the MEX-file name extension for the current
    platform. 

    ALLEXT = MEXEXT('all') returns a struct with fields 'arch' and 'ext' 
    describing MEX-file name extensions for all platforms.

    There is a script named mexext.bat on Windows and mexext.sh on UNIX
    that is intended to be used outside MATLAB in makefiles or scripts. Use
    that script instead of explicitly specifying the MEX-file extension in
    a makefile or script. The script is located in $MATLAB\bin.

    See also MEX, MEXDEBUG.

【讨论】:

    【解决方案2】:

    接受 ScottieT812 和 dwj 的建议,我发布自己的解决方案以赚取积分。

    函数computer 返回我正在运行的架构。所以:

    switch computer
        case 'GLNX86'
            display('32-bit stuff')
        case 'GLNXA64'
            display('64-bit stuff')
        otherwise
            display('Not supported')
    end
    

    为我工作

    【讨论】:

      【解决方案3】:

      这真的有效吗?你用的是哪个版本的matlab?

      据我所知,64 位平台以“64”而不是 86 结尾。来自 matlab 网站 http://www.mathworks.com/access/helpdesk/help/techdoc/ref/computer.html 我认为计算机不会返回 GLNXA86 而是返回 GLNXA64。

      所以这个问题是针对 GNU Linux 32 位或 64 位版本的。

      如果您正在测试任何 64 位平台,那么您可能需要测试最后 2 个字符以找到“64”,即类似

      if regexp(computer,'..$','match','64'),
         % setup 64bit options
      else,
         % 32bit options
      end
      

      【讨论】:

        猜你喜欢
        • 2011-05-13
        • 2012-10-26
        • 2012-11-03
        • 2012-06-12
        • 2012-03-12
        • 1970-01-01
        • 2015-01-18
        • 1970-01-01
        • 2012-07-26
        相关资源
        最近更新 更多