Running on 32 or 64 bit matlab?

浪尽此生 提交于 2019-12-23 08:59:25

问题


How can I determine if I'm running on a 32bit or a 64bit version of matlab?

I have some pre-compiled mex-files which need different path's depending on 32/64bit matlab.


回答1:


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:

>> 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:


Taking up on ScottieT812 and dwj suggestions, I post my own solution to earn some points.

The function computer returns the architecture I'm running on. so:

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

works for me




回答3:


Does this really work? Which version of matlab are you using?

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.html I don't think that computer will ever return GLNXA86 but GLNXA64 instead.

So this question is specific to GNU Linux 32bit or 64bit version.

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

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


来源:https://stackoverflow.com/questions/196885/running-on-32-or-64-bit-matlab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!