在 32 位或 64 位 matlab 上运行?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/196885/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Running on 32 or 64 bit matlab?
提问by peje
How can I determine if I'm running on a 32bit or a 64bit version of matlab?
如何确定我是在 32 位还是 64 位版本的 matlab 上运行?
I have some pre-compiled mex-files which need different path's depending on 32/64bit matlab.
我有一些预编译的 mex 文件,它们需要不同的路径,具体取决于 32/64 位 matlab。
采纳答案by peje
Taking up on ScottieT812 and dwj suggestions, I post my own solution to earn some points.
根据 ScottieT812 和 dwj 的建议,我发布了我自己的解决方案以赚取积分。
The function computerreturns the architecture I'm running on. so:
该函数computer返回我正在运行的架构。所以:
switch computer
case 'GLNX86'
display('32-bit stuff')
case 'GLNXA64'
display('64-bit stuff')
otherwise
display('Not supported')
end
works for me
对我来说有效
回答by Vebjorn Ljosa
The question of 32 vs. 64 bits is really a red herring. If I understand correctly, you want to determine which set of compiled MEX files are needed so you can set the path appropriately. For this, you can use the function mexext:
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.
回答by Adrian
Does this really work? Which version of matlab are you using?
这真的有效吗?你用的是哪个版本的matlab?
As far as I'm aware the 64 bit platforms end with "64" not 86. From the matlab site http://www.mathworks.com/access/helpdesk/help/techdoc/ref/computer.htmlI don't think that computer will ever return GLNXA86 but GLNXA64 instead.
据我所知,64 位平台以“64”而不是 86 结尾。来自 matlab 站点 http://www.mathworks.com/access/helpdesk/help/techdoc/ref/computer.html我不知道认为该计算机将永远返回 GLNXA86 而不是 GLNXA64。
So this question is specific to GNU Linux 32bit or 64bit version.
所以这个问题是针对 GNU Linux 32 位或 64 位版本的。
If you are testing for any 64bit platform then you probably need to test the last 2 characters to find "64" i.e. something like
如果您正在测试任何 64 位平台,那么您可能需要测试最后 2 个字符以找到“64”,即类似
if regexp(computer,'..$','match','64'),
% setup 64bit options
else,
% 32bit options
end

