Mike on the MATLAB Desktop
November 7th, 2011
The New Spreadsheet Import Tool
One of the most exciting new features in MATLAB R2011b is the Spreadsheet Import Tool. This tool makes it easy to import data from Microsoft Excel and comma-separated value (CSV) files. The spreadsheet import tool allows you to preview the file and then select the range and format of the data to import. To get started it’s as easy as double-clicking the any .csv or .xls file in the Folder Browser.
For this example, I went to data.gov to get a random CSV file. It’s an awesome place for getting sample data sets or to answer burning questions like “how much Sorghum did the US import in the 70′s?”
Here’s what the new tool looks like when I use it to import a CSV file:
By default the tool wants to import the data as a matrix, using zeroes to fill in gaps. By using the toolbar, you can quickly customize this process. The first drop-down lets you choose between matrix, column vector, or cell array for the data type. The matrix and cell options will import into one variable, and the column vector will create a variable for each selected column. The variables can be quickly renamed by typing in the trapezoidal area at the top of the selection.
This tool is highly interactive. You can quickly choose a subrange using all the normal multi-select gestures (e.g. shift & control click) for your platform. The selections don’t have to be contiguous, but each column has to have the same rows selected, which the tool enforces when you drag around a selection. You can also select a whole row or column by click on its respective header.
You also have several options for deciding how to treat blank or non-numeric data. You can set up rules to have rows or columns containing such data automatically excluded, or to have that data replaced by a number, Inf, or NaN. When you do this, those cells are a highlighted in different colors with the new values super-imposed over the original. This allows you to quickly scan the data to make sure you get the desired results.
Finally you can import immediately into the workspace or generate a script or function that would allow you to process other files in the same manner. This is particularly useful if you work with multiple data sets generated in the same fashion.
For a more dynamic look at how to use this tool, watch the short video.
By
Michael Katz
Mike is a developer on the MATLAB Mobile team. When not describing himself in the third person, biking, homebrewing, or rooting for the home team, he's busy trying to make the world a better place for programming.
18:49 UTC |
Posted in Data Tools |
Permalink |
No Comments »
October 31st, 2011
Celebrating Our Community Milestones
I was just looking at a few things at MATLAB Central. It struck me that some really interesting things are going on that I wanted to share.
MATLAB Answers
Most of you probably remember that MATLAB Answers was launched in January. Since launch, we have had over 17,500 questions asked, over 13,000 answers made, and over 38,000 community members participated by asking questions, offering answers or comments to questions! It’s been really amazing watching all the activity that has been going on since the begining of this year. It is the contributions by each of our community members that makes MATLAB Answers, and MATLAB Central for that matter, such a great success.

Eight members of our community have become MATLAB Answers Editors, by achieving a reputation of 1500. In addition to participating by answering your MATLAB questions, our editors also help make MATLAB Answers an even better place by editing questions, answers or comments. If needed, they can also remove content. Thanks to all of our Editors for all their hard work. You can read more about what they do in Guidelines for Editors on MATLAB Answers.

Fall Contest Starts Wednesday

It’s that time again! The Fall Contest begins at noontime Natick time/16:00 UTC, Wednesday November 2. Please join us for another fun season testing your MATLAB skills against other members of our community.
If you haven’t played before, read about past contest winners in our Hall of Fame, or watch Ned as he talks about how the contest team creates the game each season. We hope to see you online!
Happy Anniversary Ned!

If you’ve been part of the MATLAB Central community for a while, you’ve probably read blog or newsgroup posts, watched a video or downloaded File Exchange submissions from Ned Gulley, one of the founders of our community. Ned is celebrating his 20th anniversary at MathWorks.
Please join us in wishing him a very happy anniversary!
By
Helen Chen
Helen is part of the MATLAB Central team. She spends her days hanging out with really cool folks online at MATLAB Central and at MathWorks HQ in Natick.
00:49 UTC |
Posted in MATLAB Central |
Permalink |
No Comments »
October 24th, 2011
Function Name Case Sensitivity in MATLAB R2011b
I can barely remember a MATLAB version that did not produce an inexact case match warning if you used the wrong capitalization of a function name. Now, the days of willy-nilly capitalization in MATLAB are over. Starting in R2011b, that long-time warning is now an error.
Here is the warning message in R2010a by calling “foo.m” with the command “Foo“:
Warning: Could not find an exact (case-sensitive) match for 'Foo'.
../foo.m is a case-insensitive match and will be used instead.
You can improve the performance of your code by using exact
name matches and we therefore recommend that you update your
usage accordingly. Alternatively, you can disable this warning using
warning('off','MATLAB:dispatcher:InexactCaseMatch').
This warning will become an error in future releases.
As promised, R2011b is the future release where this is now an error:
Cannot find an exact (case-sensitive) match for 'Foo'.
Do you want: foo
(in ../foo.m)?
This error identifier for this message is the same as the old warning: 'MATLAB:dispatcher:InexactCaseMatch'. If you still have any misspelled functions in your code, they should be spot by running the code and looking for these errors. Before launching your main script, run the command:
dbstop if error MATLAB:dispatcher:InexactCaseMatch
and your program will pause whenever this error occurs.
By
Michael Katz
Mike is a developer on the MATLAB Mobile team. When not describing himself in the third person, biking, homebrewing, or rooting for the home team, he's busy trying to make the world a better place for programming.
19:57 UTC |
Posted in Programming |
Permalink |
8 Comments »
October 17th, 2011
R2011b Command Window Formatting Improvements
In this latest release we have a number of new formatting improvements in the MATLAB Command Window.
Easier to read errors
In old releases if there was an error when running a file, MATLAB would display an error like:
??? Error using ==> myfun2 at 1
As of R2011b, the formatting is different so it’s easier to read, and to navigate to the issue. In the same red text, it will now be formatted like:
The function name will appear as a link that opens the doc page for that function, if available. The line number (if not a built-in a function) will be a link that opens that file in the Editor.
Orange Warnings
Warning text that appears in the command window will be colored orange to make them easier to spot. Like almost all our colors, this is configurable in the Preferences window if you have trouble seeing it: File -> Preferences -> Colors -> MATLAB Command Window colors.
Formatted Help
Help displayed in the command window now bolds the function name as it appears in the help text.
By
Michael Katz
Mike is a developer on the MATLAB Mobile team. When not describing himself in the third person, biking, homebrewing, or rooting for the home team, he's busy trying to make the world a better place for programming.
15:17 UTC |
Posted in Command Window |
Permalink |
6 Comments »
October 3rd, 2011
Comparison Tool Updates in R2011b
This week I’d like to welcome back guest poster, Malcolm Wood, to describe the enhancements to the File and Folder Comparison tool.
Over the last few releases we have made some major enhancements to the Comparison Tool in MATLAB, giving you more flexibility over what you can compare, more detail about the differences, and in some cases the ability to merge changes from one file to another.
In previous releases you could compare folders with other folders, ZIP-files with other ZIP-files, and Simulink manifest files with other Simulink manifest files. But since R2010b you can compare any of these with any other, treating each as a container for a list of files. So if you created a back-up of your work in a ZIP-file one day, you can use the Comparison Tool to examine the differences between the back-up and the folder containing your current work:
In R2011a we implemented some improvements to the MAT-file comparison report. It now shows the data types and sizes of your variables, and there’s the option to “merge” the differences between the files (1), i.e. to copy a variable from one file to the other. Be careful with this, because there’s no easily accessible “undo” feature for MAT-file merge. Instead, a back-up file is created to help you in case you make a mistake, and the report includes instructions on how to recover the previous values (2).
The other major new capability here is the option to compare the contents of the variables. Clicking the little magnifying glass icon (3) opens the “Variable Comparison” window. There are several different views, depending on the data type. Here is how it looks for a structure:
And by double clicking on a field in the structure you can compare the values inside. This is how it looks for the “hand2” field, which is a numeric array:
We have also introduced some features to make it easier to concentrate on the important changes between text files. In R2010b we made it possible to ignore differences that involve only the number of “whitespace characters” in a line or between lines (4). So if all you did was change the indentation in your MATLAB code, these won’t show up as differences, leaving you to focus on changes which actually matter to your results. And in R2011a we made it possible to hide sections of the file which contain no changes (5), saving you a lot of scrolling if you are looking at only a few changes among thousands of lines of text.
Those of you who work on both Windows machines and Linux or Unix machines may be familiar with the problem of trying to compare files which use different types of end-of-line character. Some differencing tools will show every line as different, making it impossible to see where the actual text has changed. Others will ignore the end-of-line characters, perhaps leaving you scratching your head as to why two files of different sizes are reported as being identical by your differencing tool.
In R2011b we have two features to help you. Firstly, when comparing files as text and finding no differences to display, MATLAB will also check the sizes of the files and include the result in the report (6).
Secondly, we enhanced the “Binary Comparison” report so that it can show the individual bytes that are different. By clicking the “New Comparison” button (7) and choosing “Binary Comparison” in the dialog you can generate a report like this one which enables you to see the additional carriage-return bytes (8):
By
Michael Katz
Mike is a developer on the MATLAB Mobile team. When not describing himself in the third person, biking, homebrewing, or rooting for the home team, he's busy trying to make the world a better place for programming.
13:37 UTC |
Posted in Current Directory |
Permalink |
No Comments »
September 27th, 2011
MATLAB Tour 2011 Begins in Boston

The MATLAB Tour 2011 kicked off yesterday here in Boston! I had the privilege to attend this awesome one-day event. Here are my notes:
Keynote Presentation
Practicing data driven research is not easy. You have too much data to analyze or you don’t know how to validate your models with your data. The keynote demonstrated how you can use MATLAB and Simulink to tackle these common challenges. One demo used Parallel Computing Toolbox to speed up the analysis of large meteorological data sets and the other demo employed Model-Based Design to bring hybrid cars from conception to production. Don’t worry if you don’t know much about meteorology or hybrid car design, as the examples are used to illustrate how MathWorks tools can help you practice data driven research.
MATLAB and Simulink updates
Following the keynote, the MATLAB Today presentation covered many noteworthy MATLAB features introduced in recent years. I have listed my favorite ones here:
I know this blog is catered to MATLAB users, but some of the Simulink updates are also very intriguing.
Afternoon Sessions
The afternoon sessions focused on specific topics and workflows in MATLAB or Simulink. I attended two sessions.
Data-Fitting Techniques with MATLAB
If you are interested in questions like “Which mathematical model do I use?” or “Which parameters are most important in my model?” you will want to join the data fitting session and learn some MATLAB techniques and functions. You can get an abridged version of the material in this webinar.
Generate, Verify, and Integrate C Code from Your MATLAB Algorithms
If you are curious to see MATLAB Coder in action, this session provides a walkthrough of integrating your application into a C environment. There are some serious time savings using this workflow.
Final Thoughts
Aside from learning new features at this event and win some prizes, it is a great opportunity to network. I certainly enjoyed my conversations with the attendees. Take advantage of MATLAB Tour 2011 by attending at one of these locations!
21:37 UTC |
Posted in Uncategorized |
Permalink |
1 Comment »
September 19th, 2011
A Little Reminiscing on College
Chilly mornings and turning leaves reminded me of my college days at Cornell. A long fourteen years ago I was an engineering freshman, uncertain if I wanted to learn electrical engineering, computer science, or material science, or if I should forget the whole thing and go into theatre instead. Even now, I still haven’t made up mind: I’m a software developer despite having degrees in electrical engineering and neuroscience.
Unlike most of my peers, my first experience with MATLAB came in my first semester. I took a mid-level computational analysis class, foolishly ignoring its perquisites. I had to buy MATLAB 5.0 student version in the campus bookstore for $99. I’ve previously posted my answer to the first homework assignment. I aced that first problem set, but the class got exponentially harder as the semester wore on. I wish had tutorials like these when I was new user (http://www.mathworks.com/academia/student_center/tutorials/) .

Two sophomore-year classes sealed me to electrical engineering and signal processing: Digital Electronics Lab, where we programmed logical circuits with NANDs and ORs, etc., and Signals and Systems, where I first learned about impulse responses and FFTs. Those are two of the few classes where I can still recall what I learned. In later signal processing classes I relied on MATLAB to find filter coefficients, determine stability and calculate and visualize (and hear) outputs of various filter algorithms. It’s too bad I didn’t have the Filter Design Toolbox then!
But it was the project courses in my junior and senior years that I found most impactful. Bruce Land’s embedded systems class in particular was my favorite. Thanks to the professor’s foresight my final project has been immortalized on the web. From this page you can see my early skills in web-design, Photoshop, and GUI building. In particular this project was an early stop on a continuing theme in my life: building systems with remote MATLAB processing. Warning: it may be a bit NSFW and does not reflect my current opinions.
The professor for that course also worked in the Neurobiology department. Between his influence and few other courses in computational psychology, bioengineering and a EE lab where we built EKG analyzers, I decided my next step was to go to grad school in Neuroscience. If you’re ever in Cornell’s engineering library, you can check out my thesis… it’s filled with MATLAB code modeling fish brains. It was this detour into biology that kindled my love of data analysis and visualization, which got me to come to MathWorks to help build a better MATLAB. Speaking of which, we’re still hiring: http://www.mathworks.com/company/jobs.
If you’re in college, or at least in heart, tell us about your MATLAB experiences below.
By
Michael Katz
Mike is a developer on the MATLAB Mobile team. When not describing himself in the third person, biking, homebrewing, or rooting for the home team, he's busy trying to make the world a better place for programming.
16:00 UTC |
Posted in Uncategorized |
Permalink |
1 Comment »
September 12th, 2011
Variable and Function Rename
The MATLAB R2011b feature that I’ve been most anticipating is the automatic rename in the Editor. Renaming functions and variables is a common operation for programmers. It’s useful for making code easier to read and understand. For example, I often start hacking together a script by using easy-to-type names like “a“, “b“, and “a2.” I then piece together a script or function from those commands, but I don’t want to save my code like that–I’d never be able to read what I did in order to understand it! What I really want is to replace “a” with something like “derivedTimes” and “b” with “voltage“.
In the olden days, I used find & replace for my renaming needs. This was fine, but required me to select the variable first, type out the whole new name, and then make sure I didn’t replace any partial words or variables in other functions. The new rename function simply takes care of all that for me. It only rennames matching functions or variables (the search is symbol-based, not text-based) in the same scope. The best part is that you can start typing and it will do the rename of all that matching names in-place… no dialogs or mouse movements needed.
To give it a try, just open up any function or script, palace the caret on a variable name (on the left of an expression), and start typing.
This feature has only a few simple rules when it will appear:
- It only renames variable if you type on the left side of an expression or in a function’s argument declaration.
- Functions are only renamed from the function declaration.
- You can’t rename special variable names like varargin and varargout.
If you don’t want to use this feature and are bothered by the pop-ups, you can disable it from the preferences: File -> Preferences -> Editor/Debugger -> Language -> MATLAB -> “Variable and function renaming”.
For more information, check out the documentation or watch the video.
By
Michael Katz
Mike is a developer on the MATLAB Mobile team. When not describing himself in the third person, biking, homebrewing, or rooting for the home team, he's busy trying to make the world a better place for programming.
17:47 UTC |
Posted in Editor |
Permalink |
8 Comments »
September 5th, 2011
R2011b Is Here!
It’s (almost) fall, and that means a brand-new release of MATLAB. Here are a few awesome new Desktop features in this release:
|
The Command Window has gotten some improved formatting. Error messages have a modern look with the function where the error occurred’s name in bold and linked to its a doc. Warning messages will appear in orange. And command window help bolds the function name wherever it appears in the doc. |
|
The editor now allows you to quickly rename all instances of a variable or a function at once, within a file. Watch the video. |
|
The new Spreadsheet Import Tool allows you to select ranges of data and define rules for handling nonnumeric values. This tool opens instead of the Import Wizard for spreadsheets and comma-separated value (CSV) files. Watch the video. |
By
Michael Katz
Mike is a developer on the MATLAB Mobile team. When not describing himself in the third person, biking, homebrewing, or rooting for the home team, he's busy trying to make the world a better place for programming.
12:40 UTC |
Posted in Command Window, Editor, Releases |
Permalink |
12 Comments »
August 22nd, 2011
The Go To Dialog
Over the weekend, reader “mnasr14″ reminded me with a comment on an old post about the oft-overlooked Go To… dialog in the Editor. The Go To… dialog provides a quick way to jump to a point in an open Editor document by line number, function name, or cell title.
This dialog is easily launched from Go -> Go To… or by pressing Ctrl+G on Windows or ⌘+L on Mac. From there you can either input a line number, or select a function name or cell title (if there are any in the document).
That’s it… just a simple way to jump around a large file without needing to search or scroll.
By
Michael Katz
Mike is a developer on the MATLAB Mobile team. When not describing himself in the third person, biking, homebrewing, or rooting for the home team, he's busy trying to make the world a better place for programming.
17:39 UTC |
Posted in Editor |
Permalink |
2 Comments »
|
Recent Comments