- Undocumented Matlab - https://undocumentedmatlab.com -

Undocumented feature() function

Taking a short break from Java-related stuff in Matlab, I wanted to share and expand a reply I posted [1] a short while ago on the StackOverflow forum, in response to a reader’s request to explain Matlab’s feature function. This article uses pure Matlab and is absolutely unrelated to Java, so those of you who are Java-phobic can be at ease trying this at home…
feature is an entirely undocumented and unsupported Matlab function, and unlike most other undocumented Matlab functions it actually does often change without prior notice between Matlab releases, so be very careful when using this function in your code.
feature accepts two arguments: the name of the feature and an optional new value. This is similar to get/set functions: When only one argument is supplied, Matlab returns the current feature value (like get), otherwise the value is modified (like set). In some rare cases (feature(‘timing’)), a third input argument is sometimes expected.
Feature names are case-insensitive. The built-in function system_dependent appears to be a synonym for feature (not exactly – some system_dependent features are unavailable in feature…). We can find several references to system_dependent online, mostly for old Matlab releases. There’s even an entry in the official Matlab FAQ [2] (which has no usful info), and I’ve seen online references [3] going all the way back to 1993…
One of the very rare official comments about this function says [4]:

The system_dependent function is an unpublished function that we use for a variety of crufty things. It will most certainly change from time to time and possibly even go away completely. The system_dependent function performs different functionality on each of the platforms supported by MATLAB.

Several feature options have been reported over the years, mainly on the CSSM forum and also seen in the installed Matlab code base, as listed below (the code references are from the latest Matlab release – 7.10, aka R2010a). Note that many of these features may not work on your platform:

Oddly, some features are only accessible via system_dependent, and not via feature:

The following are OpenGL [32]-related features that are used in the opengl.m function:

If you lasted this far you deserve a special treat: Last but not least we have feature(‘dwim’) [33]. Unfortunately, this feature sometimes fails on some systems…
Have you discovered or used any interesting feature? If so, please do share them in the comments section below

27 Comments (Open | Close)

27 Comments To "Undocumented feature() function"

#1 Comment By Donn Shull On May 4, 2010 @ 10:02

Hi Yair, the following feature is only useful to people with Simulink and Real-Time Workshop Embedded Coder. If you open a block diagram for example:

>> rtwdemo_fuelsys

you can obtain the object instance for your block diagram with:

>> obj = get_param(bdroot, 'UDDObject')

This object has a lot of useful methods but many of them raise an exception for example:

>> obj.getCompiledBlockList
??? Simulink engine interface is not enabled.

Using the engine interface feature will enable those methods

>> feature('EngineInterface', 1)

Will enable those methods.

On a related topic as an alternative to using handle to obtain the object for handle graphics items you can create them with a “package qualified” command and they will return the object rather than a numeric handle. for example:

>> figObj = hg.figure
figObj =
	figure

Thanks for all the hard work,

Donn

#2 Comment By walderich On August 27, 2014 @ 00:42

Thanks a lot for the “EngineInterface” feature. But in my case I had to set its value to 1001 to get it working. I tested this with Matlab versions R2010b-R2014a.

#3 Comment By Ondrej Konopka On July 17, 2010 @ 03:47

Hi Yair, I found out additional features in R2008b. Meanings of features are obvious from names of features in case of features with capital letters. The rest of features i have no idea what it does.

feature(‘alloclist‘)
feature(‘CachePath‘)
feature(‘CheckMallocClear‘)
feature(‘CheckMallocDispTaggedCallSite‘)
feature(‘CheckMallocEnableAsserts‘)
feature(‘CheckMallocLogTaggedCallSites‘)
feature(‘CheckMallocLog‘)
feature(‘CheckMallocNumStackFrames‘)
feature(‘CheckMallocTagCallSites‘)
feature(‘CheckMemoryIntegrity‘)
feature(‘ClearMemoryStats‘)
feature(‘ClearPcodeStats‘)
feature(‘CoreDump‘)
feature(‘DirectoryFreeze‘)
feature(‘DirectoryUnfreeze‘)
feature(‘DirsAddedUnfreeze‘)
feature(‘DumpHeap‘)
feature(‘InteruptLongjumps‘)
feature(‘IsDMLWorker‘)
feature(‘LogAllStreams‘)
feature(‘logfile‘)
feature(‘pallalloc‘)
feature(‘pallleaks‘)
feature(‘pclalloc‘)
feature(‘pclleaks‘)
feature(‘pcovclear‘)
feature(‘pcovdisable‘)
feature(‘pcovenable‘)
feature(‘pcovisrunning‘)
feature(‘pcovsavedata‘)
feature(‘pcovsetfilename‘)
feature(‘plogprint‘)
feature(‘pnewalloc‘)
feature(‘pnewleaks‘)
feature(‘PrintMemoryCacheStats‘)
feature(‘PrintMemoryStats‘)
feature(‘PrintPcodeStats‘)
feature(‘prompt‘)
feature(‘purify‘)
feature(‘qclear‘)
feature(‘qewait‘)
feature(‘qsavefile‘)
feature(‘qsave‘)
feature(‘qstart‘)
feature(‘qstop‘)
feature(‘quantify‘)
feature(‘TestUDD‘)
feature(‘uddcount‘)
feature(‘valgrind‘)
feature(‘vlogprint‘)
feature(‘vnewleaks‘)

Hopefully, it helps you improve these pages. Thanks for the hard work as well.

Ondrej

#4 Comment By Yves Piguet On February 18, 2011 @ 06:01

Is this one known?

feature list

Try

l = feature('list');
for i = 1:length(l)
  fprintf('%35s has_cb=%d has_bi=%d calls=%d val=%g\n', ...
    l(i).name, l(i).has_callback, l(i).has_builtin, l(i).call_count, l(i).value);
end

#5 Comment By Yair Altman On February 18, 2011 @ 06:40

@Yves – this is fantastic 🙂

#6 Comment By Aurélien On April 11, 2011 @ 00:29

Reading this bug report this morning : MATLAB crashes during debugging
[40]
I discovered other feature commands and of cours I immediately think about sharing this on your blog :

1. Turn off the JIT in the offending program file using the command “feature scopedAccelEnablement off”.
2. Turn off the jitting of structures using the command “feature jitallow structs off”.
3. Turn off the JIT completely using the command “feature accel off”

#7 Comment By Yair Altman On April 11, 2011 @ 05:53

Thanks for the tip, Aurélien 🙂

#8 Pingback By Converting Java vectors to Matlab arrays | Undocumented Matlab On December 14, 2011 @ 11:55

[…] It so happens, that the undocumented built-in feature function (or its near-synonym system_dependent) enables improved performance […]

#9 Pingback By Profiling Matlab memory usage | Undocumented Matlab On March 1, 2012 @ 08:43

[…] in release R2008a (but not on newer releases) we could also use a nifty parameter of the undocumented feature function: >> feature mtic; a=ones(100); feature mtoc […]

#10 Comment By damayi On May 22, 2012 @ 12:39

Can you tell me what is the difference between feature(‘IsDebug’) and feature(‘IsDebugMode’);
What’s more, I found that feature(‘IsDebugMode’) will always get false result when you run it in you m code, but in debug command, you can get true. why?

#11 Comment By Alexander On October 23, 2012 @ 09:47

You could also add: system_dependent(7) which toggles command window text buffering. It can help if you output very large strings.

Btw, is there a way to query the current state? Or set it to on/off (not just toggle)? I.e. I don’t want to toggle it on and off – I just want to turn that off once.

#12 Comment By Yair Altman On October 24, 2012 @ 07:27

@Alexander – I don’t think you can query or set the state of this specific feature. In other features you can, but not here.

#13 Comment By Rye On April 2, 2013 @ 12:09

I found this feature while trying to debug a bizarre error I was having with a GPU function:

feature('GpuAllocPoolSizeKb')

found this here: [41]

#14 Comment By Yair Altman On April 2, 2013 @ 14:17

@Rye – thanks

#15 Pingback By Using Java 7 in Matlab R2013a and earlier | Undocumented Matlab On June 19, 2013 @ 12:08

[…] R2013a does not have this problem; for R2012b a solution was found by setting the undocumented UseOldFileDialogs feature: feature('UseOldFileDialogs', […]

#16 Pingback By Undocumented feature list | Undocumented Matlab On March 19, 2014 @ 11:02

[…] Three years ago I posted an article on Matlab’s undocumented feature function. feature is a Matlab function that enables access to undocumented internal Matlab functionality. […]

#17 Comment By Holger Krause On April 3, 2014 @ 07:28

Matlab running on linux uses server-side font rendering. In case, the server doesn’t provide requested fonts, text in figures is rendered in a default font, and changes in fontsize are without effect. This can be overcome with:

feature('javadrawingmethods',2)

In this mode, java seems to do the text rendering wihout relying on Xservers capabilities.

Tested in R2014a and R2013a.

#18 Pingback By Unicode characters in MATLAB source files – DexPage On July 9, 2015 @ 10:25

[…] can read more about this undocumented function here. See also this Matlab Central thread for other […]

#19 Comment By Karel Lebeda On September 23, 2016 @ 17:01

Is it me, is it Linux, or has this gone (in 2015a)?

>> which feature
built-in (undocumented)

>> feature memstats
Error using feature
Feature memstats not found
 
>> edit feature
(opens /opt/MWmatlabR2015a/toolbox/distcomp/@distcomp/feature.m)

#20 Comment By Yair Altman On September 23, 2016 @ 18:05

@Karel – feature memstats is a Windows-only feature

#21 Comment By matlab On November 13, 2016 @ 00:08

Thanks for kind useful information.

#22 Comment By Kristian Loewe On November 28, 2016 @ 18:26

It seems that feature(‘OpenGLLoadStatus’) has been dropped. It’s still available in R2014b but not in R2015b (Linux versions). Do you know if it’s still available in R2015a?

#23 Comment By Yair Altman On December 25, 2016 @ 18:50

@Kristian – yes, feature('OpenGLLoadStatus') works in R2015a. It would be interesting to know how you are using this feature – can you tell us?

#24 Comment By Kristian Loewe On March 7, 2017 @ 12:46

Thanks, Yair!

I am using it to assert that OpenGL is available upon starting up a GUI that I am developing. The GUI requires OpenGL in order to work as expected.

#25 Comment By Erivelton Geraldo Nepomuceno On May 12, 2017 @ 20:04

Hi,

system_dep​endent(‘se​tround’,In​f) is still working on R2017a? Anyone has noticed something different? In previous version, I didn’t find any problem.

#26 Comment By Walter Roberson On June 22, 2018 @ 04:31

feature('COM_PassSafeArrayByRef', 1)

to turn on passing SAFEARRAY by reference to COM objects.

Described in [42]

#27 Comment By Yair Altman On June 25, 2018 @ 22:02

Thanks @Walter. Another related undocumented feature is

feature('COM_SafeArraySingleDim', 1)

, which makes SAFEARRAYs that are exported to COM objects 1-dimensional, rather than 2D (which is Matlab’s default). See discussion in [43].