在32位还是64位的Matlab上运行?

7

我如何确定我正在运行32位或64位版本的matlab?

我有一些预编译的mex文件,这些文件需要根据32/64位matlab使用不同的路径。


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

6

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.

5

参考了 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

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接