Matlab installation take 2

It’s that time of the year again. With Matlab 8.0 (R2012b) now available for download, I once again installed a new release. Today’s post will detail some of the post-installation steps I did for the new installation to work properly, for me at least. Nothing special compared to past releases, but worth listing anyway I guess. I won’t bother repeating the list that I published here exactly one year ago.

Removing extra files

Since my complaint last year, I see that some (not all) of the Japanese-language files have been removed from the installation. This is good, although some large Japanese files remain (e.g., the installation guide PDF and many help files) which a smart installer (or even better – the JNLP downloader) might know to ignore based on my computer’s locale.

In any case, what has been added to my dislike, are files in Chinese, specifically the helpsearch_zh_CN folder in %matlabroot%/help/ and %matlabroot%/help/matlab/, each weighing a hefty 14MB. I really hate giving Matlab the adjective of “bloatware”, but its releases keep getting larger and large (R2012b weighs over 800MB!) and I feel that a lot of it, like these Chinese files, could be avoided with only a little bit of extra care on the part of MathWorks. Not all computers have 100GB of free disk space, you know…

Modifying some Matlab m-files

I have several standard changes that I often make to Matlab files. These changes are naturally not propagated when installing a new Matlab release. I can understand this and I’m not complaining. I just need to go over the list of functions and re-modify them:

  1. profview and matlab-report-styles.css (both in %matlabroot%/toolbox/matlab/codetools/) – I’ll post a separate article about this next week, together with some additional undocumented profiling options that I did not cover in my previous article on this topic.
  2. uitree, uitab and other semi-documented functions (mostly in %matlabroot%/toolbox/matlab/uitools/) such as the useful hgfeval – add a % character at the beginning of line #3, in order to make the help section become visible during help or doc.

Preferences, workspace

This is one step that I do not need to do when installing on a machine having a previous Matlab installation. The installer is smart enough to detect that installation and copy its preference files to the new installation. However, updating the default preferences is indeed necessary for a fresh install, and since I was asked about this I thought to include this here.

So here are the changes that I normally make to the default preferences:

  1. General – Confirmation Dialogs – uncheck several confirmations
  2. General – Java Heap Memory – increase to 256 or 512MB
  3. Keyboard – check the <Tab key narrows completion> option (most useful for the desktop – see related article)
  4. Fonts – Monospaced 10pt => Courier New 8pt (the Monospace font is often displayed incorrectly, as a proportional rather than fixed-width font. Using Courier solves this problem. 8pt gives me more real-estate and still looks good on my display)
  5. Colors – Programming Tools – check all the options except <Show lines between sections>
  6. Command Window – Text display: long g compact; uncheck <Show getting started msg>; scroll buffer: 5K=>25K (will MathWorks ever increase this hard-coded limit?!)
  7. Editor – Most recently used (MRU): 4=>12 (until recently Matlab only supported 9, hurray)
  8. Editor – Display – check all options (on some older releases the <Show lines between sections> was here and needed to be unchecked; this option is now in Colors – programming Tools); Show line at 75 => 120 columns
  9. Editor – Tab – check all options
  10. Editor – Language – Max column width: 75 => 120; Indent all functions (not just nested)
  11. Editor – Code Folding – check all options in the <Enable> column; check most options in the <Fold Initially> column
  12. Editor – Autosave – Append file name with asv => ~
  13. GUIDE – uncheck all options except <Show file extension in window title>

And in the Workspace panel, only show the Name, Value, Bytes and Class columns (right-click the column headers to select).

A few words about R2012b

The new R2012b release has received the version ID of 8.0. Despite my speculations in 2010 (here and here) that Matlab 8.0 will bring along the promise of the much-awaited HG2, it turns out that I was incorrect. The new release still does not incorporate HG2. We can see a gradual progression in the work by starting Matlab with the “-hgVersion 2” switch that I described there, but this has still not made it into the mainstream figure window. Hopefully we will get HG2 sometime next year.

R2012b does include a major facelift to the Desktop and Editor, using the new MS-Office-like toolstrip that I exposed here last year. Some people hate toolstrips, some love them, but whatever your personal preference is, Matlab does not have an option to switch back to the non-toolstripped appearance, so for good or worse we’re stuck with the new look. The new toolstrip is currently shown only in the Desktop and related tools, not in figure windows (perhaps in anticipation for HG2? I don’t know). Which reminds me that it’s really about time for me to write a detailed technical article explaining how to add a toolstrip to figure windows.

Another thing you’ll notice in the new release is a facelift to the documentation and the Matlab browser (tabs, finally!), along with a Quick Access Bar (QAB) and a Win7-like current-folder combo-box control.

Matlab's new look (click to zoom)

Matlab's new look (click to zoom)

One specific new features that readers of this blog (I, for one) will probably bless, is the ability to create a custom user Java static classpath and librarypath files, that will override and extend Matlab’s auto-generated classpath.txt and librarypath.txt files. The new custom files should be called javaclasspath.txt, javalibrarypath.txt and be placed in your prefdir or startup folder (the latter is useful for deployed applications). This finally puts an end to the need to update these files for each Matlab release, along with the ensuing compatibility problems that arose from incompatible set of Matlab JAR files. This solves a very painful operational issue for me and I’m sure that also for others.

Another Java-related improvement is the ability to get the underlying Java exception object in the catch part of a try-catch block. Not a biggie for me, but certainly a nice-to-have.

Sadly, if you’re looking for really important engine upgrades, then I haven’t found any that really caught my eye in the release notes. Maybe next year…

Categories: Desktop, Low risk of breaking in future versions

Tags: , ,

Bookmark and SharePrint Print

32 Responses to Matlab installation take 2

  1. Aurélien says:

    Definitely agree with the last sentence . Ok like the website of TMW , MATLAB has a new face ,a new look but what else?!!!
    There is no major improvement for GUIde since many years !

    I see more compatibility issue with the recent changes (since 12a) of the unique , intersect, setdiff … functions

  2. neusgaten says:

    Custom documentation has not been integrated in the new help viewer. One needs to be redirect to the old help browser to open custom documentation.

  3. David says:

    Thanks for this list. One thing I always do for a new release is copy/paste my customizations to TC.xml for tab completion (thanks for your previous blog post about that!).

  4. Brad Stiritz says:

    Hi Yair,

    Regarding the long-dreamed-of “Handle Graphics 2” (HG2) functionality that seems to be taking TMW so long to get where they want it: I’m still not getting whether the visible componentry of HG2 (what you can actually render with it) will be updated, or simply the programming implementation?

    You’ve written extensively on your blog & in your book about how outdated the visual elements are that come out of MATLAB Guide. Definitely! In some respects they remind me of Windows 95! Clearly when we look around the web & see what other people have done in the last 10 years, it’s just very sad to see TMW lagging behind so badly.

    Here’s one stark example: take a look at the GUI elements in any of the user-contributed Mathematica demos, such as Polar Area Sweep. Don’t the sliders & left-hand selection gallery look so much more modern?

    I’ve also noted that Khan Academy has started a series of videos on basic programming, using what looks like an interpreted JavaScript environment. It was super-buggy when I checked it out a few weeks ago, but given how ambitious Sal Khan is to revolutionize education, I wouldn’t be surprised to see very impressive UI before long.

    What’s your take on the evolution of UI elements & style in MATLAB?


  5. Malcolm Lidierth says:

    As often happens, many useful features available in the old menus have disappeared in the toolstrip. If you have a “favourite” menu item that has disappeared, its relatively painless to add to the toolstrip e.g. :

    jButton = javax.swing.JButton('Close All');
    hButton = handle(jButton, 'callbackproperties');
    set(hButton, 'MouseClickedCallback', 'close(''all'')');
  6. Ron says:

    Hi Yair,
    The javaclasspath.txt is clearly a great improvement on the previous approach of editing classpath.txt.
    However it only allows one to place additional jar files at the end of the static path, after all the matlab jar files.
    I have a set of jar files, which I did not write and do not understand, which only work if they are placed before the the matlab jar files. Is there any to do this in R2012b?

    • @Ron – you could always add your jars to the main classpath.txt file, as in previous releases.

    • Ron says:

      Thanks, I forgot that the system classpath.txt may be editable for Windows installs of Matlab. However on Linux root access is normally required to edit the system classpath.txt, and just adding a local classpath.txt before starting Matlab no longer has any effect. I guess the work around is then just to say “you need root access to install this software”. I assume there is no way in R2012b for a non-root user to place jars at the head of the static path?

    • @Ron – try using the new -nouserjavapath startup parameter. This disables javaclasspath.txt so maybe it restores the previous startup-folder classpath.txt functionality. If not, you’ll need to edit Matlab’s installation version of this file, with all the permission issues that this entails. In such a case, I suggest that you contact MathWorks to find you a fix, because this would be a regression in functionality that should be unacceptable. Please let us all know what you learn.

    • Ron says:

      Hi Yair,
      Thanks for the suggestions. The -nouserjavapath flag does not seem to help. I contacted Matlab and they provided a work around that can do what I want, but they admit it may be slightly more inconvenient than previously:
      (1) make a copy of the updated classpath.txt in any directory other the one in which matlab is to be started
      (2) set the environment variable MATLABPATH to point to this directory (on windows you have to also add the path to toolbox/local)
      (3) restart matlab.

    • @Ron – “slightly more inconvenient” – that’s quite an understatement…

      And how exactly would MathWorks suggest that this would be done for deployed (compiled) applications???

  7. Malcolm Lidierth says:

    has been included as the 1st line of classpath.txt since since R2011b (I think).

    It’s problematic, as some of the jars shipped with MATLAB are legacy copies (e.g Apache Math 1). Whether all of these are used in MATLAB is unclear and requests for info from TMW usually come with a caveat emptor clause. The presence of those legacy jars may (??) explain why your jars “only work if they are placed before the matlab jar files” as the class loader will load the first jar requested.
    Perhaps this is the price that has to be paid for a “works out of the box” package like MATLAB. To see whether that price is worth paying – try using one of its open-source clones for an hour or two (if tempted also look at a non-clone, the R stats environment, which also gives access to Java including AWT/Swing; Mac users might try the JGR incarnation if you want AWT/Swing support).

  8. Roy says:

    Can someone plz share the r2012b installation key and the license? :p im a poor grad student

  9. Arthur Ward says:

    I’m surprised you left out disabling the “Startup Accelerator.” By default, it preloads MATLAB at login, around 8am, and around noon. If I don’t disable the “accelerators,” with three versions of MATLAB installed that equals nine disk cache blowouts a day, slowing down everything else I’m doing afterwards. Not acceptable.

    • @Arthur thanks. You are quite right, this is one of the first things I do after installing Matlab. I don’t know why I forgot to mention it in the article.

  10. Zohar Bar-Yehuda says:

    It seems a new annoying issue came with the new version.
    When working with very large and complex struct arrays, running the “whos” command may take several seconds. In past version, if the “workspace” window was open, MATLAB would refresh it after every command, causing slow responsiveness in some cases. But if you closed the “workspace” window it didn’t happen.

    Now it seems to refresh it behind the scenes even when the “workspace” window is closed.
    Any idea how to fix this?


    • Brian says:

      Hi Zohar,

      I just ran into the exact same problem…I’ve been using matlab 2007b for years with 4000 variables in the workspace…suddenly everything got super slow. I closed the workspace browser and it went back to normal for a while, but now it is slow again (even with the browser closed).

      The last thing I remember doing before the great slow down was performing some of Yair’s post-installation steps. I don’t think that was the cause and I certainly wouldn’t want to blame Yair and his unbelievably wonderful website…but i’m at a loss to explain this problem.

      I have since un-installed matlab 2007b and reinstalled matlab 2007b and the problem persists!

      I ran the profiler and it says its the “whos” function that is sucking up all the time….even when doing a simple 1+1 on the command line.

      If anyone knows how to solve this problem…i would be eternally grateful.

    • @Brian – Matlab updates the Workspace variables whenever focus returns to the Command Window prompt. If you start the Profiler, then run a simple function in the Command Window, then stop the Profiler and display the results, you will be able to see all the internal Matlab functions that are invoked to refresh the vars list. You said that you have 4K variables and this certainly explains the slowdown. As you said yourself, Matlab spends an enourmous amount of time in the whos function, which is used to get the latest Workspace information before updating the Workspage GUI table.

      Suggestion – check whether you really need 4K vars. In all likelihood you don’t. It would be much better to use simple numeric arrays ([1,2,3]), or cell arrays ({1,2,3}) or a struct with separate fields (a.var1, a.var2) or a combination of these. This should drastically reduce the number of active variables in your Workspace. A normal Workspace should not have more than 20-30 variables. The internal Matlab refresh will then be correspondingly short.

    • Brian says:

      Yair, Thanks for the suggestion. But as I said, I’ve been running this simulation for years without problems. Many other people in the office are still running the same simulation without problems. Something I did recently triggered this slow down. And when I say slow down…I mean it takes 8 seconds to do 1+1 ! It has almost made matlab useless for me.

      Matlab seems to acknowledge the problem:
      but doesn’t really provide much of a solution:

      “There is an issue with the MATLAB Workspace browser in the way that JAVA renders all the base workspace variables when the Workspace browser is open during simulation.
      As a workaround, close the MATLAB workspace browser during simulation. “

    • You may be encountering memory-swapping issues, so try restarting the computer and monitoring the process memory while running your simulation. I’m afraid I don’t have anything smarter to suggest except contacting MathWorks customer service.

  11. Roderick says:

    Hey Yair,

    Any idea about how the new javaclasspath.txt handles duplicate dependencies to the standard Matlab included jars? Does Matlab actually do something with duplicate dependencies and with potential version conflicts in this case?

    Fyi, for the last couple of days I’ve been boxing my head against a wall trying to get a big java project imported into Matlab. To handle version conflicts in the dependencies (which there are and which I can find with trying to add separate jars to the dynamic path), I’ve tried using the Maven shade plugin for renaming all common classes between matlab and my java project and packaging this into one big jar. Seemed like a decent approach. However, after trying to add this final jar to either the static or dynamic classpath, I don’t get any errors from Matlab and it signals that it has indeed added it when calling javaclasspath(), while I cannot call into any class located within this jar. I’ve tried different routes of finding out why Matlab doesn’t pick it up, but cannot seem to get anywhere.

    • @Roderick – indeed, Matlab is not very verbose when failing to instantiate a class as to the underlying failure reason (to say the least). You could try placing all your classes as standalone files in some folder and then add the folder via javaaddpath, then you would at least be able to test on a class-by-class basis. You should run which(FQCN) before the javaaddpath, to ensure that the class is not already defined somewhere in Matlab. If all your classes reside in a dedicated package (e.g., roderick.MyClass) then this should not be an issue. This would then narrow things down to an instantiation problem. Ensure that both your class AND its constructor are public, then ensure that your are passing the correct params to your constructor.

      If all this fails, then a possible reason is that the class references some other class that is not available on the java classpath. For example, class A might call B.method() somewhere (in whichever function), and if B is not available then instatiating A in Matlab will fail without telling you that the actual reason is B and not A…

      A final reason might be that the class files were compiles using a newer Java release than Matlab is using – a typical case is using Java 7 rather than Java 6.

    • Roderick says:

      Thanks for the feedback,

      I’ve got it working a bit better now it seems. The main solution seems to have been to extract my final jar and add this directory to the Matlab java classpath rather than to the jar itself. I was able to add the directory to both the static and dynamic path and the classes subsequently seem available. This means that it seems I can rely on Maven shade plugin to deal with duplicate dependencies and potential version conflicts.

      I’m aware about the java 7 problem, and have been using jvm7 in Matlab for some while now. I had to apply some patches for some issues with graphics and GUIs, and although it is still definitely not bug-free, it seems manageable. It’s a pitty that R2013a still relies on the jvm6 though.

    • Malcolm Lidierth says:

      A multi-jar ANT build, such as that produced by NetBeans should solve your problems without much effort.
      Addition of jars is a property of Java/JVM/ANT rather than MATLAB. If a class is already loaded, it will be resolvable by the JVM and not be loaded again.

      For example, with the Waterloo graphics project only one jar is added using MATLAB javaaddpath – GraphExplorer.jar. This has many dependencies in the “dist/lib” folder which Java knows about via the META-INF in GraphExplorer.jar (all generated automatically in NetBeans if you select the copy dependencies to lib folder in the build settings). Just make sure that the single jar has all second, third etc order dependencies added (as Yair describes above) i.e if A.jar calls B.jar that depends on C.jar, add C.jar as well as B.jar as a dependency to A.jar.

      When classes are already available through the MATLAB static java class path – they will be used and nothing extra will be loaded: Java/ANT resolves what needs to be loaded automatically. Problems arise only when there is a version conflict and then generally only if you are calling an unsupported function. E.g., MATLAB ships with the JOGL1 openGL Java library. To use JOGL2 you would need to edit the static class path (and, in this case, also replace the OS specific binaries).

      An advantage of this is you do not need a MATLAB-specific build. GraphExplorer.jar also runs as a standalone executable jar and it can be used from other environments e.g. R and SciLab when the dist/lib jars will all be loaded automatically.

      Also note that any jars added through loading a single jar file are then available within MATLAB. E.g, GraphExplorer is written largely in Groovy rather than Java – so Groovy and all its built-in classes are then available in MATLAB. One of those, the GroovyClassLoader can be used to add extra jar files to the class path dynamically by specifying the URL of a jar file (much as the MATLAB javaaddpath – much easier to use than the Java equivalent). GraphExplorer (which is an LGPL project) uses that to load its GPL extensions if they are installed. The advantage here is that the supporting code is in the GraphExplorer.jar file – no need to write specifically for MATLAB again so everything works also for the stand-alone, R etc.

    • Roderick says:


      Doing a multi-jar build may work, however a problem still lies in having different versions in my project’s Java code and Matlab libraries, say . Not having the new library available results in missing classes/methods for my project’s Java code, and the *.jar might not load using the Matlab classloader. Subsequently, switching to the new version of the library by modifying the static classpath.txt to load the new version results in Matlab trying to call deprecated classes or methods. To fix this would require patching the Matlab binaries which use this deprecated logic, which seems like a pretty painful job to do and to maintain for multiple Matlab machines.

      Using a tool like JarJar or Maven shade in the build process allows me to rename duplicate dependencies for my own Java project, such that my own Java code can call into a different version than the default Matlab logic. This seems required to get things working.

      On a side-note, after the issues observed with java dependencies and java 7, we’re trying to get java RMI working. This would allow running a separate jvm1.7 with its own classpath, and as such we don’t have to stress Matlab as much.

  12. Matt says:

    Any luck writing the article “add a toolstrip to figure windows”?

    • @Matt – it’s in the pipeline… Matlab’s toolstrip is not simple so investigating it and writing the article takes a long time. I hope to get around to it in a few months.

  13. Pingback: JSON-Matlab integration | Undocumented Matlab

  14. Pingback: Java class access pitfalls | Undocumented Matlab

Leave a Reply

Your email address will not be published. Required fields are marked *