Can an mfile(s) written in Matlab on Windows be run on matlab for a Mac without compatibility issues?
10 次查看(过去 30 天)
显示 更早的评论
I am running matlab R2012a on my windows x64 system. Can I send someone an mfile who is running matlab on their mac and they won't have an issue running it?
Thanks
1 个评论
回答(6 个)
Jan
2012-9-19
编辑:Jan
2012-9-20
Usually this works seamlessly. Most of the toolbox functions are provided as M-files and they run on all supported systems.
Some small details can differ, but there are built-in methods to handle them:
- Use filesep and fullfile instead hard-coded file separators.
- Do not rely on a certain location of the TEMP folder, but use the tempdir function.
- The display of complex GUIs can differ in some details, e.g. the background color of buttons.
- load failes for files in ASCII format, when the MacOS-9 line breaks CHAR(13) are used. It is easy to convert the files on demand. (Nevertheless, it is an ugly bug. I blame the DOS/MacOS/Linux designers, because they have not been able to define a common ASCII standard.)
- set(0, 'PointerLocation', [x,y]) does not work under MacOS. Linux?
0 个评论
Thomas
2012-9-19
mfiles are script/function files which are dependent on MATLAB and not the underlying OS, unless you are making system call in your mfiles. So you shoudl be able to use an mfile created in windows on OSX as long all you have all the toolboxes you require on the MAC that you had on the windows machine that are called from the script..
0 个评论
Walter Roberson
2012-9-19
Formatting of floating point numbers differs between OS-X and MS Windows.
Calculations may have different results on the two systems, due to differences in round-off and differences in compiler-level optimization. In some cases the differences can be substantial (in cases where very precise cancellation is important, or cases where the calculation is unstable.)
ActiveX can only be used in MS Windows. This includes the more advanced uses of Excel.
The graphics subsystems are different between the two. This can lead to subtle differences in plotting. It can also lead to major differences in fonts and appearance of lettering.
There are differences in media support.
2 个评论
Walter Roberson
2012-9-19
Also, MS Windows does not display numbers in full precision in some cases, which can lead to differences in files saved as text. The difference in the number of decimal places can be a fair bit.
Dan Weaver
2015-7-15
Two minor differences I've encountered:
Using "ls" won't necessarily work as expected on a Linux system if you're used to Windows. You might instead need to use "dir" or adapt your use of the ls output.
Using "\" to describe the path location won't work on Linux. Use "/" only.
1 个评论
Ferhat Kangal
2022-12-22
I have been trying to solve my problem and that answer just solved everything!! Thanks a lot!
Wayne King
2012-9-19
Yes, unless that M file is using some specific Windows system commands, or is really a mex file compiled for Windows
0 个评论
Ken Atwell
2012-9-19
As others have pointed out, differences are contained. I switch between Windows and Mac routinely, and my applications largely "just work". For me, assumptions about path separators (use filesep as Jan suggests), and keeping MEX-Files on both platforms in synch are the most common gotchas. Most toolboxes are available on both platforms, which some exceptions, mostly involving 3rd party interfaces for products not available for Macs anyhow.
I don't write a lot of GUI code, but I do know that DPI on Windows and OS X are different (one is 96 DPI, the other 72 DPI, but I forget which is which), so you may need to experiment to get a GUI that looks great on both platforms. For example, I wrote this experiment some time ago:
f=figure;
pos=get(f, 'Position');
str = '0123456789ABCDEF';
sz = 36;
if ismac sz = sz*(96/72); end
uicontrol('Style','text','Units', 'pixels', ...
'String',str, 'FontSize', sz, 'FontName', 'Courier',...
'Position', [0 0 pos(3) pos(4)]);
Experiment by comment out the "|if ismac|" statement -- note that MATLAB provides the functions ispc and ismac for convenience should you need to include platform-specific behavior.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Startup and Shutdown 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!