Ken & Mike on the MATLAB Desktop

November 2nd, 2009

Help browser search updates

Everywhere you look, searching is becoming the standard way of accessing information, and our documentation is no exception. In MATLAB R2009b we’ve updated the Help browser’s search functionality to help you find what you’re looking for more quickly. In this post I’ll give you a quick tour of the changes.

First, let’s take a look at the R2009a search results display. Using the default Help browser layout, here are the results of a search for “fft” with all MathWorks products installed:

fft_9a_doc_results.PNG

We weren’t happy that this display does not give you an easy way to differentiate among the top three results. They’re function reference pages from different products, but you’d never know it because the Product column is scrolled off the right side of the results area. If you want to see what products the results are in (or sort by product), you need to scroll over and lose sight of the title. There are a few other issues that we fixed, but that’s the big one.

Now lets see how the same search looks in R2009b:

fft_9b_doc_results.PNG

The first thing you might notice is that each result takes up a lot more vertical space, so you don’t see as many results. That’s true, but we think the new features are worth the tradeoff - we’re going for quality over quantity in the results. Let’s take a quick look at what we’ve changed:

  • There’s no awkward horizontal scrolling in the search results area, ever.
  • We’re using an icon to display the type of result - these icons are the same ones that are used in the top level of the new table of contents.
  • Demo search results are now listed together with the documentation results.
  • Each result includes some snippets from the result page, which shows the context in which the search term is used.
  • For reference pages, we’re including the summary line (for example, in the top result above we’re displaying “Discrete Fourier transform”).
  • The sorting options have changed.

About those sorting options… In R2009b sorting is all about organizing your search results. Now that we categorize results by type, that was a natural addition to the sort options. We also felt that the old options to sort by title or section didn’t provide a lot of value, so we removed them. To further emphasize the notion that sorting helps you organize your results, when you sort by type or product we group the results into collapsible sections. That way you can easily show or hide entire groups of results that you find useful or not.

We hope that these new features will help you find what you’re looking for when you search our documentation. Give them a shot and let us know what you think.

October 26th, 2009

The MATLAB Editor at your fingertips

Our friend Yair recently described on his blog how to use the various functionalities of the Editor by accessing its Java components. I imagine for many MATLAB users, especially those not familiar with Java, this is wading into unfamiliar territory. We don’t write very many APIs in Java intended for our users to access, and we like to abstract away the implementation components so we can be free to refactor behind the scenes. We’ve been spending time on refactoring projects, and so the Java APIs have been changing quite rapidly.

Over the years we’ve had a lot of requests for programmatic access to various desktop components, and we’re working on a MATLAB API for the Editor. In R2009b, this API is hidden in the product (aka undocumented), but we’re planning on bringing it out in a future release fully supported and documented. The api provides methods to manipulate the text, get information about the buffer, as well as close, save, and open editors. With the object provided users can manage the editor state, write scripts that call their favorite diff tool, open files in other programs, open the folder in the OS, etc.

The 9b version isn’t fully vetted or functional; it’s there to satisfy some back-end requirements. This means I’m officially saying not to use it and don’t complain when things don’t work, but… if you’d like to preview it, give it a go. All of the functionality is part of the editorservices package. A single buffer/file in the Editor is represented by the editorservices.EditorDocument class. These objects are constructed by calling the package functions such as editorservices.new(), editorservices.open(), and editorservices.getActive().

Here is a full list of the package function in MATLAB R2009b.

help editorservices
Contents of editorservices:

EditorDocument           - Encapsulates all user accessible behavior of the MATLAB Editor
EditorUtils              - Static utility methods for editorservices functions
closeGroup               - Closes the MATLAB Editor and all open documents.
find                     - returns an already open EditorDocument for a given file name
getActive                - finds the active (topmost) open buffer in the Editor
getAll                   - Gets all the Editors that are currently open
isOpen                   - true if the specified file is open in the editor
new                      - Creates a new buffer, with optional text
open                     - Opens the MATLAB Editor with the given filename
openAndGoToFunction      - open a file in the editor and highlight the indicated function
openAndGoToLine          - open a file in the editor and highlight the indicated line

You can try it out now, but keep in mind we’ve already already changed the API, fixed some of the bugs, and enhanced its functionality for its prime-time release, and so any code written with it will likely have to change when we release the documented API.

Please let us know how this new api fits (or doesn’t fit) into your workflows, and what future enhancements you’d like to see and what other Desktop components you’d like to work with programmatically.

October 19th, 2009

Is 7 your lucky number?


I’d like to welcome guest blogger Ken Atwell from the MATLAB Product Management team this week to talk about our support of Windows 7.

Here at The MathWorks we’ve been using and testing MATLAB against pre-releases of Windows 7 for some time now. And we know we’re not the only ones, as we’ve seen thousands of MATLAB activations under Windows 7, even though Windows 7 will not be formally release until the end of this week! I’m happy to report that we’ve fully tested and are now officially supporting the 32-bit and 64-bit versions of R2009a (including Student Version) and R2009b. You can see read our official statement here, and we’ve updated our System Requirements pages in the last several days accordingly.

We expect a smooth MATLAB experience when using these modern releases of MATLAB on Windows 7. We expect older versions of MATLAB to work as well (see our statement for potential gotchas), but is not a supported configuration. If you’re using R2009a, we did find one glitch unique to Windows 7 that was fixed for R2009b: If you shell out to the console with the ! shell escape “operator” in MATLAB, Ctrl+C often will not break out of an operation should you choose to abort it. There is no work-around beyond “don’t do that”. Again, this was resolved for 9b and seems to impact Windows 7 only.

Here are two nice usability improvements that I thought I would share:

  1. If you mouse over the MATLAB icon in the Windows taskbar, you’ll get thumbnails of all of your MATLAB windows. This may be helpful when you need to locate an undocked Figure window of a GUI that got itself stacked under the MATLAB Desktop or another application.

  2. The “Windows” key on your keyboard will pop-up the Start menu, which you can quickly filter by typing a character or two in the name of the app you wish to launch. No more hunting through the Program Files hierarchy! For me, Windows->”fi” is enough to find Firefox, Windows->”it” is enough to find iTunes, and (of course) Windows->”ma” finds MATLAB. This is great way to find and launch frequently-used applications while keeping your hands on the keyboard. (And, okay, I admit this feature was introduced in Windows Vista, but it is just too good not to share!)

What are your plans for migrating to Windows 7 (or are you already there)? Any productivity tips for fellow MATLAB users?

-by Ken Atwell, The MathWorks

October 12th, 2009

The history of keyboard shortcuts in MATLAB


I’d like to welcome guest blogger Christina Roberts from the MATLAB Editor team. Christina was the lead developer on the configurable keyboard shortcuts feature.

My last post gave an overview of how to use the new keyboard shortcut preference panel. This post is going to delve into the history of keyboard shortcuts in MATLAB, which will help make it clearer why we decided to change some of our default keyboard shortcut assignments.

The MATLAB desktop was developed over many years by a number of different developers. Although the developers attempted to follow platform standards for common actions, some MATLAB-specific actions were assigned different keyboard shortcuts in different desktop tools, depending on which developer created the tool. A good example of this, illustrated below in the legacy R2009a Windows Default Set, is the Open Selection action available across the desktop. In addition to the four different shortcuts that you can see below, there are a few tools with the action that have no shortcut at all.

Further complicating issues, the original keyboard shortcuts assigned to the Command Window were based on Emacs, regardless of platform. Other platform-specific shortcuts were also added to the Command Window, as long as they did not conflict with existing Emacs shortcuts; for example, Ctrl+O was added on Windows to perform Open, but Ctrl+A could not be assigned to the Command Window’s Select All action because Ctrl+A was the Emacs assignment for moving the cursor to the beginning of the line.

Before long, customers began asking for the ability to configure keyboard shortcuts in the Editor and Command Window, which were the primary desktop tools at the time. To help accommodate those requests, three default sets were developed for the Editor and the Command Window, and users could choose between those sets independently (with the caveat that the Macintosh set was only available on the Macintosh platform). To maintain backwards compatibility, the defaults remained as they had been, even though they were inconsistent between the Editor and the Command Window—the Command Window stayed with the Emacs-based shortcuts on all platforms, but the keyboard shortcut set selected for the Editor by default varied by platform. This was very confusing for new MATLAB users, who expected a more consistent user experience.

As MATLAB continued to evolve, additional tools were added to the desktop, and their keyboard shortcuts were hard-coded to the values that the individual developers felt made sense. So although users appreciated having some choice of keyboard shortcuts in the Editor and Command Window, we continued to receive many requests for customization of individual keyboard shortcuts across the whole desktop. This was particularly needed for customers using certain non-English keyboards, which simply could not trigger some of our default shortcuts.

Presented with the challenge of creating a new keyboard shortcut infrastructure, I had several requirements. I wanted to provide a way to unify keyboard shortcuts across desktop tools so that, by default, the same action had the same shortcut, regardless of where it was triggered. However, I knew that making such a change would introduce backwards incompatibilities and possibly annoy existing MATLAB users, so I wanted to ensure that flexibility existed for customers to achieve exactly the same hybrid configurations that we previously supported. At the same time, this flexibility could not be burdensome to users who desired to quickly change a keyboard shortcut across the desktop, without dealing with individual tools.

So now let’s take a look at the solution that I developed, using the Ctrl+A example discussed above. First, compare the Ctrl+A assignments in the new Windows Default Set to the assignments in the legacy R2009a set.

New Windows Default Set as of R2009b


Old Windows Default Set as of R2009a

In R2009a on Windows, Ctrl+A was not assigned to Select All in the Command Window, and instead had the Emacs-based assignment of Cursor Begin Line. Now, let’s assume that you are an existing MATLAB user and you have Ctrl+A committed in your muscle memory to going to the beginning of the line. You have 2 options—you can revert back to the legacy R2009a Windows Default Set, or you can modify the Select All and Cursor Begin Line assignments in the new default set.

Modifying the new default set is a far better long term solution if there are a relatively small number of keyboard shortcuts that are bothering you. If you stick with our new default sets, as new actions and tools are added to the desktop, you will automatically obtain their keyboard shortcuts—this is because we only store the customizations (differences) that you have made from our shipping defaults. In contrast, the legacy sets are complete listings of exactly what we had in release R2009a, and they will not evolve with new features.

So let’s change the assignments related to Ctrl+A in the new Windows Default Set. To do this, first click on Select All and then un-assign the Command Window from the list of tools with the Ctrl+A shortcut.

Then select Cursor Begin Line, press the button, and add a new shortcut of Ctrl+A to the Command Window only.

If you now search for Ctrl+A in the table of actions, and you will see that the assignments match the ones in R2009a.

That is a quick summary of how the new customizable keyboard shortcuts were developed. I hope that you find this feature useful, and I’d love to hear your feedback!

-by Christina Roberts, The MathWorks

October 8th, 2009

Midweek update: MATLAB Virtual Conference next week October 14th

MathWorks is hosting a MATLAB virtual conference on Wednesday, October 14. It’ll basically be like a regular conference but all the events, meetings, booths, etc will be online.

I will be facilitating forum discussions on MATLAB tips and tricks from 2-3pm and 4-5pm (Eastern). Fellow bloggers Loren and Jiro will also be hosting forum discussions.

October 5th, 2009

Slimming down the Help browser


I’d like to welcome guest blogger Chris Kollett this week from the MATLAB Help team to talk about the redesigned Help Browser.

If you’re a regular user of the Help browser, you’ll notice that its user interface has changed quite a bit in R2009b. One of our main motivations for these changes was to make the Help browser useful in layouts other than its default layout. Time and time again we’ve seen users struggle to use the Editor and Help browser at the same time, because they both work best when they’re laid out relatively wide. Since users can’t get them both on screen at the same time, they end up switching back and forth between them, wasting time and breaking their flow.

If you struggle to see your work and use the Help system at the same time, here are a couple of tips for making the Help browser take up less space in R2009b:

Close the Help navigator

Yes, really, close the Help navigator (the left side of the Help browser, where the table of contents and the search results show up). It used to be that if you closed the Help navigator you wouldn’t be able to navigate the doc at all - the table of contents, demos, and even the search field would go away with it. In R2009b, we’ve moved the search field up into the toolbar when the Help navigator is closed, and even more significantly, we’ve replaced the old location dropdown with a breadcrumb navigation widget that lets you access to the full table of contents and all of the demos from the toolbar. If you’ve always wanted the Help browser to give more space to the documentation without sacrificing so much functionality, R2009b should be a big improvement for you.

R2009b Help Browser Breadcrumb Navigation

Consider a taller, narrower Help browser

Prior to R2009b, it was virtually impossible to use the Help browser once you made it narrow. The Help navigator could only be positioned on the left hand side of the Help browser, and as we discussed above, you lost a ton of functionality if you tried to close it. So if you made the Help browser narrow, you had very little room left to display the documentation. In R2009b, we’ve introduced an alternate layout for the Help browser: if you resize the Help browser so that it’s tall and narrow, the Help navigator moves up above the contents. We’re hoping you’ll find it convenient to try some alternate layouts, like docking the Help browser in a narrow space next to the editor.

R2009b Help Browser Narrow Layout

Please try out these changes and let us know if they help keep you in your flow - we don’t want you to get bogged down in the Help browser and lose track of your work. We’ll look at some other changes to the Help browser in a later entry.

September 28th, 2009

Configurable keyboard shortcuts have arrived


I’d like to welcome guest blogger Christina Roberts from the MATLAB Editor team. Christina was the lead developer on the configurable keyboard shortcuts feature.

R2009b has a new feature that I am particularly excited about: user-configurable keyboard shortcuts for the MATLAB desktop. This is a project that has been in the works for several years, and I am thrilled that it is now officially released.

I will be splitting up my discussion of this feature into two posts. The first will give a high-level overview of the R2009b functionality, and the second will delve into the somewhat troubled history of keyboard shortcuts in MATLAB. I hope that you will learn some valuable tips from both posts and gain a better understanding of how to leverage customizable keyboard shortcuts.

First, let me explain the layout of the keyboard shortcut preference panel. You can open it from the File Menu: File -> Preferences -> Keyboard -> Shortcuts


The Active settings dropdown list at the top of the preference panel allows you to choose between different keyboard shortcut sets—those that ship with the product, and customized sets that you may obtain from colleagues or MATLAB Central. The shortcut set selected by default matches common keyboard shortcuts on the platform on which you are running. For Windows and Macintosh, these are based on Windows and Macintosh platform standards, respectively. On UNIX, we decided to base our default keyboard shortcuts on the popular Emacs editor; however, if you are more comfortable with Windows-based keyboard shortcuts, that option is also available on UNIX.

The Windows and Emacs sets are both available on non-Macintosh platforms, but the Macintosh Default Set is only available on Macintosh due to the usage of the Command key. In addition to our new default sets, we also ship a set representing the default keyboard shortcuts in R2009a, specific to the platform on which you are running.

To import a customized keyboard shortcut set, choose Browse… from the Active settings combo box and navigate to the location of the set’s XML file. If you would like to share your own customized set, use the Save As… button to create an XML-representation of the set.

The top table of the preference panel lists all the actions that are configurable. You can search the contents of this table using the search field above it. For example, let’s look at the actions relating to pasting an item from the clipboard:



You can see that there are three paste-related actions. The generic Paste action has the keyboard shortcuts Ctrl+V and Shift+Insert. These same keyboard shortcuts are also assigned to Paste to Workspace in the Workspace Browser, as indicated by the informational icon next to the actions as well as their tooltips.

The middle table is where you can change assigned keyboard shortcuts, remove existing assignments, and add new ones. Let’s assume that you want to change Paste’s Ctrl+V shortcut to Ctrl+Shift+P. To do this, click in the table cell displaying Ctrl+V and press your new keyboard shortcut. The text representing the shortcut that you just pressed will then be displayed. Note that you can also insert multi-stroke keyboard shortcuts, popular in Emacs, by selecting Limit to 2 keystrokes from keyboard shortcut editor’s context menu.

If you press the Apply or OK buttons, Ctrl+V will be replaced by Ctrl+Shift+P for all tools which support the Paste action. To see what tools these are, click in the table cell to the right of the new assignment. It is then possible to deselect some of these tools, if you do not wish for Ctrl+Shift+P to be assigned to Paste in all desktop tools.

Now let’s also assign Ctrl+V back to Paste in the Editor only. To do this, press the button under the middle table. Then press Ctrl+V in the shortcut field, and finally deselect all the tools for that shortcut except the MATLAB Editor.

Finally, the bottom table in the panel shows keyboard shortcut conflicts with the action currently being edited. In the example above, informational icons indicate that there are keyboard shortcuts assigned to Paste which are also assigned to Paste to Workspace. However, since the Workspace Browser does not support the default Paste action, this is not an actual conflict. To create a real conflict, try replacing the Ctrl+Shift+P assignment with Ctrl+P.



When you make that change, an error icon appears, indicating that Ctrl+P is assigned to two or more actions within the same desktop tool. This means that you cannot use Ctrl+P for both Paste and Print, but you can instead choose to unassign Ctrl+P from Print by selecting the first row in the bottom table and pressing the Unassign button.

If you now press the OK or Apply button, your modifications to the Windows Default Set will be retained in subsequent sessions of MATLAB. You can go back to the original Windows Default Set by selecting Restore defaults, or you could write this file out as a custom set by selecting Save As….

That is a quick overview of how the preference panel works. In a future post, I will discuss the history of keyboard shortcuts in MATLAB and explain how we made some of our design choices.

-by Christina Roberts, The MathWorks

September 21st, 2009

The Front Page of the File Exchange: Your Desktop

It may seem backward in late 2009 that one of the great new features in MATLAB is integrating a web application, the MATLAB File Exchange, into the Desktop. However it’s not surprising to me that this arrangement works out quite well. Because the file exchange exists for sharing files created in and to be used in the MATLAB environment, this actually streamlines the workflow. This new tool solves the pain of making files from the exchange available and searchable right there without having to leave MATLAB.

The File Exchange window is not open by default, so to bring it up, use the toolbar menu: Desktop -> File Exchange.

Downloading is quite simple. Let’s say I wanted to download Ken’s breakpoint muting program:
1. Search
2. Download

File Exchange search

3. Go

File Exchange search

It’s pretty a simple feature, but the convenience factor is really there. You can search for toolbox functions using the Function Browser, and if we didn’t give you a particular function, you can then turn to the File Exchange and see if one of your friends on the web has already done the work for you.

The file exchange is an active and friendly community and if you’ve come up with useful program, we encourage you to share that with the community through the File Exchange web interface. If your program is up to snuff, it may even be chosen as the File Exchange Pick of the Week.

Resources:

  1. FAQ
  2. Watch the tutorial video

September 14th, 2009

MATLAB-Emacs integration is back

I'd like to welcome guest blogger Eric Ludlam from the MATLAB Graphics team.

Little Things

Back in April of this year, Mike wrote a Desktop Blog article stating that it's the little things that count. In the comments to this article several people who were long time users of EmacsLink wrote in after discovering that the R2009a Editor interface stopped supporting EmacsLink.

As an author of a lot of Emacs code, and the current maintainer of the matlab-emacs project on Source Forge, and the guy who helped bring the original Emacs Link into existence, I was both glad to know that so many folks had found it useful, and sad that they had never joined the matlab-emacs mailing list over on Source Forge, where the many questions could be easily answered.

What is the matlab-emacs project?

The matlab-emacs project is a MATLAB mode for Emacs that consists of Emacs Lisp code that implements a major-mode for Emacs that assists in the editing of MATLAB scripts.

It also allows Emacs to be used in place of the MATLAB Editor for editing your MATLAB source code, debugging MATLAB code, and syntax/semantic checking of your MATLAB code with mlint.

The MATLAB mode for Emacs does NOT include "EmacsLink", which was a tool that more tightly integrated MATLAB and Emacs for purposes of debugging M code. "EmacsLink" only included the communication interface between MATLAB and Emacs. The editing mode has always been a part of the matlab-emacs project.

matlab-mode, which forms the root of the matlab-emacs project was first written by Matt Wette in 1991.

Where to get matlab-emacs.

The matlab-emacs project is hosted on SourceForge where the Emacs Lisp code can be downloaded from CVS.

Detailed download and installation instructions are available here.

Be sure to join the mailing list to get help on setting up and using the matlab-emacs project.

Once you have downloaded the code using your preferred method, read the INSTALL file for full details.

The matlab-emacs project has been expanded by it's users to include support for several features in CEDET. CEDET is an Emacs package that supplies an object system needed by the mlint support, and a complex completion/navigation package.

Writing MATLAB code in Emacs

Writing MATLAB code in Emacs is much like writing any other code in Emacs. The matlab-mode for Emacs has several features users have come to expect from Emacs, plus several features that make editing MATLAB code even better.

What I'm sure many users think of as a single "EmacsLink", as it shipped with MATLAB, had two parts. One part was communication between MATLAB and Emacs for debugging. The other was the MATLAB script editing mode.

Nothing has changed with the editing mode, except to make these tools even better, such as supporting the latest indentation styles, cell-mode, and programming constructs, such as the MATLAB Object System. As such, your editing experience in Emacs has only gotten better.

Setting up matlab-mode for Emacs is pretty easy. Here is an example simple setup:

    (add-to-list 'load-path "~/path/to/matlab_dot_el")
    (load-library "matlab-load")
    ;; Enable CEDET feature support for MATLAB code. (Optional)
    (matlab-cedet-setup)

In this screenshot done with Emacs 23 on Linux, you can see some syntax highlighting, and mlint support for nested functions, and bold-face cross-function variables. The blue line over the nested function, and TAGS menu is part of the CEDET support that includes function browsing and completion. It also shows if/end block matching, and CEDET summary mode showing function details.

Currenlty, the matlab-mode for Emacs supports these features:

  1. Syntax Highlighting. There are three coloring levels supported.
  2. Smart indentation. The TAB key, and RETURN key will both indent your code lines. Indent region (C-M-\) for larger areas.
  3. Code auto-fill & Paragraph fill. M-q does an excellent job on large comments. Autofill is syntax aware, and can find nice places to put line breaks in code.
  4. Syntax aware block movement. Forward/Backward sexp (C-M-f,C-M-b), and Begin/End of function (C-M-a,C-M-e) correctly moves over begin/end syntax.
  5. Paren style matching for blocks. Highlight a matching end when the cursor is on an if, and many other matching constructs.
  6. mlint support. Highlight mlint warings in your code, and a convenient conext menu for tagging and navigating through errors. Some errors can be automatically fixed by Emacs.
  7. Highlight nested variables. Using mlint, nested variables are highlighted, assiting when working with nested functions.
  8. Completion engine. Using tools in CEDET, Emacs will parse your M files and provide pretty good completion and code decoration.

How to use Emacs instead of the MATLAB Editor

OK, now to answer many of the questions that have shown up in the comments to the Desktop blog. The most common question seemed to be "Why did you take EmacsLink away?", and Mike and Ken have done a fine job answering that. The real question should be "What should I do now?"

Thankfully, I have two answers, and you can choose the one that best suites your development style.

Using Emacs as an external editor.

You can use Emacs as an external editor now in a way that is similar to what EmacsLink provided.

One of the questions that showed up on the blog was was regarding using the preference panel to set Emacs as the default editor, and the complaint was:

  1. This creates a new emacs process every time I "edit" or "open" a different function. What should happen is that only the first "edit" should start a new session, and subsequent "edit"s should open the file in the existing session. I can pretty quickly have about 30 extra windows open on my desktop.
  2. Upon an error, clicking on the error link in the matlab command window opens the official editor, not emacs, even though I specified emacs in the preferences.

The answer to these problems is to use an old Emacs tool called emacsclient. Emacslient lets you tell an already running Emacs to load a file in for editing. To enable emacsclient in your emacs, add this line to your ~/.emacs file:

    (server-start)

From the unix command prompt, you can now call emacsclient like this:

    emacsclient -n myfile.m

and myfile.m will be loaded into Emacs for editing.

After researching this problem with the Ken and Mike, I have provided some simple tools for getting this setup. The matlab-emacs project now has a toolbox directory. If you were to install matlab-emacs in the directory ~/lisp/matlab-emacs, you can now place code like this in your startup.m file:

    addpath('~/lisp/matlab-emacs/toolbox','-begin');
    rehash;
    emacsinit;

This will add the matlab-emacs project toolbox to your path, and the emacsinit script will configure MATLAB to tell an already running Emacs what to do when you type edit, or click on a link in the command window.

This screenshot shows a hand-setup where the location of emacsclient is specified as an argument to emacsinit. This is important on Windows because it may not be on your path. Now, when stopped in the debugger, you can click on the blue line number to jump to that location in some file. The file being debugged is a rubik snake demo I wrote a few years back.

This is a great step forward from just sticking the word "emacs" in the provided text field, but does not answer this question:

  1. And, of course, none of the other interactivity features are working .. no evaling code from emacs, no debugging, etc.

For this, you will need to use the Emacs command matlab-shell.

Using matlab-shell

The Emacs command M-x matlab-shell RET, on unix, will start MATLAB as a subprocess under Emacs. The command prompt will be available in an Emacs buffer the same way the unix prompt shows up if you type M-x shell.

If you use matlab-shell it will automatically configure your MATLAB as described in the previous section, allowing "edit" command to open files in a currently running Emacs. In addtion, Emacs will be able to send text from M files to the running MATLAB for execution.

Once the matlab-shell has been started, you can select "Run Region" or "Run Cell" from the menu while editing .m files. This will send the text from your source file to matlab-shell for execution.

If you just want to move the cursor to the shell, you can do M-x matlab-shell RET a second time to bring an already running shell forward.

In the above image, you can see the latest Aquamacs running matlab-shell. Selecting "Go to Last Error" or clicking the links moves the cursor to the typo that was introduced in my catapult modeling program.

To debug, you can use the toolbar to set breakpoints, or use the the db commands. For example:

    dbstop in ls
    ls
    dbstep
    dbstep
    dbquit

This will cause the ls.m file to popup in an Emacs buffer, with the debug arrow pointing at the correct line. Stepping through this file, or into new files will move the arrow to the correct place.

For windows users

MATLAB does not support a tty command window on Windows so you cannot use matlab-shell. You will still be able to use emacsclient however. To do so, you will need to modify the setup configuration like this:

    addpath('~/lisp/matlab-emacs/toolbox','-begin');
    rehash;
    emacsinit('c:/applications/Emacs/lib-src/emacsclient -n');

where you would replace the argument to emacsinit with the real path to your emacsclient binary on your system. The -n argument specifies that emacsclient should not wait for the user to finish editing the file.

Windows configuration of emacsclient is also not as easy as it is on Unix. You may need to read up on configuring your Emacsclient to work propertly before starting with the matlab-emacs configuration.

Make matlab-emacs better

The matlab-emacs project has been around for a long time, and its many contributors have made it a powerful way to work with MATLAB. If you want to Emacs as you editor, join the matlab-emacs mailing list, and help make it better.

Gratuitous Screenshot

The below screenshot includes matlab-mode with CEDET support enabled, matlab-shell running, editing, and debugging sliceomatic with ECB, the Emacs Code browser all running together.

Vim Users

For the vim users who also posted comments, the techniques used here for Emacs will also work with vim. Modifying the two MATLAB script files to call to vim instead ought to make it easy to start using vim, or just about any other editor, with MATLAB.

-by Eric Ludlam, The MathWorks

September 7th, 2009

New and Updated Desktop Features in MATLAB R2009b

R2009b (version 7.9) is here! You’d think that I’d be used to the six month release cycle by now, but there is always something to do with mad rushes interspersed with calm lulls. We’re preparing blog posts about the new features in R2009b and doing retrospectives. At the same time we’re wrapping up the development of new features in R2010a and starting to plan what we’ll do for R2010b and R2011a. It’s a long road ahead for us, but we’re working hard to incorporate all the great suggestions and feedback you’ve left us on the blog. Some of the stuff we’ll highlight over the next few weeks are things you’ve been asking for, and we’re happy to take feedback for the next iteration.

You’ll find the full release notes here. You can also find a video of the new Desktop features here. Below, I’ve called out some of my favorite new and updated Desktop features.

To get this latest release go here, or if you’re using R2008b or later, you can select Help -> Check for Updates.

Be sure to let us know what you think of these new features!

Customizable Keyboard Shortcuts
With R2009b you can customize the keystrokes associated with different actions across the desktop. As part of this we’ve had to change some of the defaults, and we’ve provided a few different sets that you might be familiar with. We’ll be explaining a lot more of this feature in future posts.

File Exchange in the MATLAB Desktop
As part of the changes that happened to the File Exchange community a few months ago (mainly BSD licensing), you are now able to search and download/upload files directly to the MATLAB file exchange.

Plot Selector
The Plot Selector has been enhanced to make it easier to select the plot type that you want. Bigger icons make it easier to see what kind of plot you’re selecting. You can also rearrange the order that the plots are shown based on which plots are most important to you.

Help Browser Enhancements
The help browser has had a significant overhaul, allowing for better listing of search results, navigation through a bread crumb bar, improved layout when the help is docked in the desktop, and an overall freshening up of the user interface. We think all of these changes will make finding and reading the documentation easier.

Current Folder Enhancements
The Current Directory Browser has been renamed the Current Folder Browser, and has received a number of updates. The biggest change is that you can now see the hierarchy of files rather than only the files in the current folder. You’ll also notice fresh new icons for the class, function and script file types. Another powerful feature is the ability to search within the current folder (including its subfolders) by pressing the magnifying glass icon next to the address bar.

Publish to PDF
The MATLAB publish function now supports PDF output.



What’s your favorite new feature or update?


Ken & Mike work on the MATLAB Desktop team.
  • Ori: The current folder shortcut used to be alt-y. Now it is alt-o. However, while in the editor window, alt-o opens...
  • Jose Miguel: Hi First of all, thanks for the post, it is really useful. I am trying to develop a Java GUI within...
  • Ken: Hi Siddharth, There isn’t currently any way to move the docking controls. Feel free to submit an...
  • Phil: I have the same problem as described above with UITable working fine in the Matlab environment but showing no...
  • Siddharth: Is there any way to move the position of the docking controls (or eliminate them through some...
  • Chris: Yes, it is a challenge to organize functions into categories, especially with so many functions. Ken and I...
  • Mike: Thanks for fielding that one, Yair.
  • Yair Altman: Jimmy - if you mean that you wish to include hyperlinks in your function’s help comment, that will...
  • OysterEngineer: Thanks for explaining the Function Browser. I fired it up and gave it a try. It appears that it has...
  • Jimmy: Is there any way to include hyperlinks in a comment, such as the standard help at the beginning of a function?

These postings are the author's and don't necessarily represent the opinions of The MathWorks.