Mike on the MATLAB Desktop
January 29th, 2012
Have you taken the Cody Challenge?
It has been such a such a busy couple of weeks at MATLAB Central! Last week, we launched Trendy, a cool new service that you can use to to plot and track trends from data on public websites. You can read more about Trendy in last week’s post.
Welcome to Cody!
This past week, MATLAB Central launched Cody, an online MATLAB game that challenges your skills and helps you expand your knowledge about MATLAB programming.

When you come to Cody, you will find many different puzzles to try to solve. Browse through available problems from the Cody home page. Use the links on the left navigation bar to browse through Community-contributed puzzles or you can choose Cody Challenge puzzles. When you first join the Cody Challenge, you will start with 3 initial puzzles to solve. Once you have successfully solved these questions, three more questions will be unlocked for you. Note that Community-contributed puzzles are always unlocked so you can jump around and try different puzzles.
Accruing Cody points
You will receive 10 points the first time you submit a correct solution for any problem either Cody Challenge or Community-contributed. Once you have the hang of solving problems, make sure that you try submitting your own puzzle. Each time you do, you will receive 15 points.
Check out scores by going to the Player’s page. Or, check out your own Cody score and history by clicking on My Cody in the left navigation bar.

Get started!
Jumping in and joining the fun at Cody is easy. All you need is to log into MATLAB Central, create your Community Profile and just pick a question to try answering. It’s easy and it’s fun. Come get started and take the Cody Challenge!
Helen
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.
20:42 UTC |
Posted in Community, MATLAB Central |
Permalink |
5 Comments »
January 16th, 2012
Introducing Trendy!
MATLAB Central is proud to announce our newest community application – Trendy a service for tracking and plotting trends.
Use Trendy to track data on public webpages by two simple steps:
- Write MATLAB Code to collect your data.
- Write MATLAB Code to visualize the collected data as trends and plots.
Trendy will collect your data daily and stores it as a trend. Trendy uses your MATLAB code to plot your data, so make sure that you come back to see what your data looks like!
Become a trend-watcher!
It’s easy and fun to see what trends have been created. Just go to Trendy to check out some plots and trends. If you want to see who are the community trend-makers, click on Owners in the left navigation bar.

Getting started creating trends
If a trend that you are interested in hasn’t been created yet, it’s easy to make your own.
To use Trendy you need to have either up-to-date SMS or MATLAB Student Version R2010a or higher. If you do, get started by logging into your MATLAB Central account.
- Use the
button to jump in and create your first trend or
- Check out the “About Trendy” link on the left navigation bar to read about how Trendy works and to access a short tutorial.

Questions or feedback?
Share your thoughts by posting your questions, comments or feedback as a comment to this blog post.
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.
14:59 UTC |
Posted in MATLAB Central |
Permalink |
3 Comments »
MATLAB Mobile iPad App
We are pleased to introduce MATLAB Mobile 3.0! This is a universal app, with UIs for both iPad and iPhone. You can download it today from the App Store.

What’s New in MATLAB Mobile Version 3.0
- MATLAB Mobile iPad app
Many of you have been asking for a dedicated iPad app. It’s here, enjoy!
- Redesigned figure and snapshot views
Figures and snapshots are combined into a single list for a streamline interface and easy access to a gallery of all the plots you have ever created on the device.
- Better zooming capabilities for 2D figures
When you have a live 2D figure, you can now zoom with the axes fixed.
- New keys and symbols in extended keyboard
Typing MATLAB code can still be a bit foreign on phones and tablet devices. We’ve added several commonly used keys to our extended keyboard. Tap and hold to discover more options.
- Automatic parentheses matching
This is my favorite app feature in this release. We all know brackets and parentheses are widely used in MATLAB code. This saves you the headache of closing and matching brackets.
If you have an iPhone or iPad give us feedback for this version!
13:24 UTC |
Posted in MATLAB Mobile |
Permalink |
32 Comments »
January 9th, 2012
Update to Running files from the Editor
Another R2011b change was recently discussed in a MATLAB Answers question. This change is when you use the run button in the MATLAB editor, the name of the script/function will be displayed in the Command Window.
Here is a visual example of that change:
From a MATLAB interpreter/workspace view there is no change in behavior. In previous versions, when you pressed the run button, that file’s active Run Configuration would evaluated in the base workspace. If you had not created or modified the run configuration, this would the same as typing the file’s name at the command prompt (assuming that the file was top on the Path). The change in R2011b is that we now show the file name in the Command Window and History as if you had typed it at the prompt and pressed Enter.
We made this change for clarity and consistency. What we want is for you to have a record of what was evaluated and be able to understand why the workspace is in its current state. This way if a script updates some variables, you’ll know what was run to cause those updates.
This does get a little more confusing if you have a run configuration, as the file name is displayed before the run configuration is evaluated, so the recorded output might not be the same as if you just ran the file directly from the command line.
Unfortunately, for some editor-centric workflows, this may decrease readability, as the original Answers poster found. Fortunately our own Scott answered with a workaround:
As a workaround, you could use the “Evaluate entire file” button on the second row of the editor toolbar (along with the other buttons for evaluating one cell at a time). If this button doesn’t appear, you can right-click on the toolbar to customize it and add the button back.
You can also assign a keyboard shortcut to the “Evaluate Entire File” action from File -> Preferences -> Keybaord -> Shortcuts. You can even reassign F5 to this action from its default “Run or Continue Execution.”
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.
14:43 UTC |
Posted in Command Window, Editor |
Permalink |
2 Comments »
January 3rd, 2012
Using the Help Report
Last week Jiro picked addcopyright for the File Exchange Pick of the Week. The pick looks like a helpful tool for adding copyright text to MATLAB program files, but while reading the post, I was reminded of the Help Report, which is part of MATLAB’s current folder reports.
The Help Report scans the .m files in the current folder and analyzes the text help at the top of the file. This is the text displayed in the Command Window, when you use the help command. The report is most useful if you want to create MathWorks-style help for your own code, but is still useful even if you use only a part of it.
One of the features the report has is the ability to flag a missing Copyright or update a Copyright line if it is out of date. It also checks for H1 text, examples, “see also”, and even scans class methods for help text.
To run the help report, go to the Actions “gear” in the current folder browser, and select Reports -> Help Report. This generates a HTML report of each file in the current folder and what help pieces are present. You can use the checkboxes at top to deselect the parts of help you don’t care about for your files.

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.
09:54 UTC |
Posted in Current Directory |
Permalink |
No Comments »
December 26th, 2011
2011 In Review
Well another year is almost complete. Once again we had two successful releases: MATLAB R2011a and R2011b. Today I feel like listing some of our achievements and share some interesting stats.
Top 11a Features
- Screen Menus on Mac OS X
- Updated Plot Catalog
- Submit a Support Request from MATLAB
Top 11b Features
- Spreadsheet Import
- Rename Variable
Web and Mobile
- MATLAB Answers
- Updated File Exchange
- MATLAB Mobile 2.0/2.1
I am most proud, of course, with MATLAB Mobile 2.0, which allows you to connect to the MathWorks Computing Cloud from your iPhone or iPod touch. No set up is needed to run MATLAB commands from anywhere!
As for the blog, I did have a few empty weeks, which I hope to not repeat next year. We got a new blogging platform this year, and it has made my life easier. This year I had 5 guest posters for a total of 47 posts. I don’t have access right now to the number of visitors, but it’s grown quite a bit this year… so, welcome all new and returning readers!
Our most popular post, by comments, remains the MATLAB Mobile announcement from last year. This is mostly due to Android fans. Rest assured we haven’t forgotten you. The most popular post, by comments, this year is the MATLAB on Mac update. Over the years, it seems that our Mac fans are the most prolific commenters.
In 2012 you can look forward to some signification desktop improvements, and cool new platforms for exploring MATLAB. Happy New Year!
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.
09:26 UTC |
Posted in Uncategorized |
Permalink |
Comments Off
December 19th, 2011
MATLAB Startup Accelerator
Another new feature of MATLAB R2011b is the Startup Accelerator, which improves MATLAB startup time on Windows by caching important files that MATLAB needs to properly launch. This is done through a scheduled task that runs periodically to update the cache. In a normal installation of MATLAB, there is nothing you need to do to get this benefit. Hopefully by now you’ve noticed R2011b loads faster than previous releases.
In case you’re curious, you can read this solution http://www.mathworks.com/support/solutions/en/data/1-FBGXHZ/index.html?solution=1-FBGXHZ. It explains how the Windows Task Scheduler is used and how to install the Startup Accelerator on a network installation of MATLAB.
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:51 UTC |
Posted in Preferences, Windows |
Permalink |
1 Comment »
November 28th, 2011
Using Dates in MATLAB
Three weeks ago I wrote about MATLAB's new spreadsheet import tool. Since then I've had a few conversations regarding using dates in MATLAB; dates are common as column headers or table data. The import tool will turn Excel dates into MATLAB datenums. A datenum in MATLAB is just a double that represents any date & time after midnight Jan 1, 0000 AD. MATLAB comes with several useful functions for handling these special case numbers, and in particular for displaying them.
The now, clock, and date functions will provide the current date & time as a datenum, datevec, or detestr, respectively. While a datenum is a single number representing the date and time, a datevec splits the year, month, day, hour, minute, and second components out in 1x6 vector. A datestr is the string representation of a date time. There are a ton formatting options available for how the date and time are displayed (see below).
currentTimeAndDate = now
currentTimeAndDateAsVector = clock
currentDateAsString = date
currentTimeAndDate =
7.3484e+05
currentTimeAndDateAsVector =
2011 11 28 8 50 20.486
currentDateAsString =
28-Nov-2011
As far as the data is concerned, these three date types are interchangeable using the conversion functions. You can use the datenum, datevec, and datestr functions to convert between the three types. Individual functions that perform calculations on dates usually prefer a particular format, for example addtodate looks for datenum types.
currentDateAsNumber = datenum(currentDateAsString)
currentDateAndDtimeAsNumber = datenum(currentTimeAndDate) %note the difference from above
currentDate = datestr(currentTimeAndDate)
currentDateAsVector = datevec(currentDateAsString)
currentDateAsNumber =
734835
currentDateAndDtimeAsNumber =
7.3484e+05
currentDate =
28-Nov-2011 08:50:20
currentDateAsVector =
2011 11 28 0 0 0
The usage of dates I'm particularly interested in is with plots. Let's say we have some time-varying data and we want the x-axis to reflect those dates. If I just plot the data against the datenum, by default the x-labels will all be large, ugly numbers.
firstInMonths = repmat([2011 1 1 0 0 0],12,1);
firstInMonths(:,2) = 1:12;
bar(datenum(firstInMonths),rand(1,12)*10)
Thankfully, MATLAB comes with a simple function, datetick, for turning those numbers into strings:
datetick
Unfortunately, those tick labels aren't very pretty. Let's use a date format with the datetick function to specify how we want labels to look. For this function, we can use any date format recognized by the detestr function (see below).
datetick('x','mmm-yy')
Finally, for your reference, here is the help information for datestr, which lists how to formate a date string:
help datestr
DATESTR String representation of date.
S = DATESTR(V) converts one or more date vectors V to date strings S.
Input V must be an M-by-6 matrix containing M full (six-element) date
vectors. Each element of V must be a positive double-precision number.
DATESTR returns a column vector of M date strings, where M is the total
number of date vectors in V.
S = DATESTR(N) converts one or more serial date numbers N to date
strings S. Input argument N can be a scalar, vector, or
multidimensional array of positive double-precision numbers. DATESTR
returns a column vector of M date strings, where M is the total number
of date numbers in N.
S = DATESTR(D, F) converts one or more date vectors, serial date
numbers, or date strings D into the same number of date strings S.
Input argument F is a format number or string that determines the
format of the date string output. Valid values for F are given in Table
1, below. Input F may also contain a free-form date format string
consisting of format tokens as shown in Table 2, below.
Date strings with 2-character years are interpreted to be within the
100 years centered around the current year.
S = DATESTR(S1, F, P) converts date string S1 to date string S,
applying format F to the output string, and using pivot year P as the
starting year of the 100-year range in which a two-character year
resides. The default pivot year is the current year minus 50 years.
F = -1 uses the default format.
S = DATESTR(...,'local') returns the string in a localized format. The
default (which can be called with 'en_US') is US English. This argument
must come last in the argument sequence.
Note: The vectorized calling syntax can offer significant performance
improvement for large arrays.
Table 1: Standard MATLAB Date format definitions
Number String Example
===========================================================================
0 'dd-mmm-yyyy HH:MM:SS' 01-Mar-2000 15:45:17
1 'dd-mmm-yyyy' 01-Mar-2000
2 'mm/dd/yy' 03/01/00
3 'mmm' Mar
4 'm' M
5 'mm' 03
6 'mm/dd' 03/01
7 'dd' 01
8 'ddd' Wed
9 'd' W
10 'yyyy' 2000
11 'yy' 00
12 'mmmyy' Mar00
13 'HH:MM:SS' 15:45:17
14 'HH:MM:SS PM' 3:45:17 PM
15 'HH:MM' 15:45
16 'HH:MM PM' 3:45 PM
17 'QQ-YY' Q1-96
18 'QQ' Q1
19 'dd/mm' 01/03
20 'dd/mm/yy' 01/03/00
21 'mmm.dd,yyyy HH:MM:SS' Mar.01,2000 15:45:17
22 'mmm.dd,yyyy' Mar.01,2000
23 'mm/dd/yyyy' 03/01/2000
24 'dd/mm/yyyy' 01/03/2000
25 'yy/mm/dd' 00/03/01
26 'yyyy/mm/dd' 2000/03/01
27 'QQ-YYYY' Q1-1996
28 'mmmyyyy' Mar2000
29 (ISO 8601) 'yyyy-mm-dd' 2000-03-01
30 (ISO 8601) 'yyyymmddTHHMMSS' 20000301T154517
31 'yyyy-mm-dd HH:MM:SS' 2000-03-01 15:45:17
Table 2: Free-form date format symbols
Symbol Interpretation of format symbol
===========================================================================
yyyy full year, e.g. 1990, 2000, 2002
yy partial year, e.g. 90, 00, 02
mmmm full name of the month, according to the calendar locale, e.g.
"March", "April" in the UK and USA English locales.
mmm first three letters of the month, according to the calendar
locale, e.g. "Mar", "Apr" in the UK and USA English locales.
mm numeric month of year, padded with leading zeros, e.g. ../03/..
or ../12/..
m capitalized first letter of the month, according to the
calendar locale; for backwards compatibility.
dddd full name of the weekday, according to the calendar locale, e.g.
"Monday", "Tuesday", for the UK and USA calendar locales.
ddd first three letters of the weekday, according to the calendar
locale, e.g. "Mon", "Tue", for the UK and USA calendar locales.
dd numeric day of the month, padded with leading zeros, e.g.
05/../.. or 20/../..
d capitalized first letter of the weekday; for backwards
compatibility
HH hour of the day, according to the time format. In case the time
format AM | PM is set, HH does not pad with leading zeros. In
case AM | PM is not set, display the hour of the day, padded
with leading zeros. e.g 10:20 PM, which is equivalent to 22:20;
9:00 AM, which is equivalent to 09:00.
MM minutes of the hour, padded with leading zeros, e.g. 10:15,
10:05, 10:05 AM.
SS second of the minute, padded with leading zeros, e.g. 10:15:30,
10:05:30, 10:05:30 AM.
FFF milliseconds field, padded with leading zeros, e.g.
10:15:30.015.
PM set the time format as time of morning or time of afternoon. AM
or PM is appended to the date string, as appropriate.
Examples:
DATESTR(now) returns '24-Jan-2003 11:58:15' for that particular date,
on an US English locale DATESTR(now,2) returns 01/24/03, the same as
for DATESTR(now,'mm/dd/yy') DATESTR(now,'dd.mm.yyyy') returns
24.01.2003 To convert a non-standard date form into a standard MATLAB
dateform, first convert the non-standard date form to a date number,
using DATENUM, for example,
DATESTR(DATENUM('24.01.2003','dd.mm.yyyy'),2) returns 01/24/03.
See also DATE, DATENUM, DATEVEC, DATETICK.
Reference page in Help browser
doc datestr
If you're interested in using dates with MATLAB, here is a link to the date functions that are available.
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:49 UTC |
Posted in Figure, Programming |
Permalink |
4 Comments »
November 21st, 2011
4 Uses of MATLAB Mobile This Thanksgiving
1. Chef Aide
When cooking a large meal, I often need to make quick calculations and substitutions. For instance, how to handle measuring when all my tablespoons are in the sink? After pre-loading the Units Conversion Toolbox from the file exchange into MATLAB, I can figure out a workaround lickety-split:
Sure there are plenty of apps that will do this easier and out of the box, but that’s not as much fun as using MATLAB.
2. Black Friday Deal Calculator
How do you know how much are you going to save on a deal? In addition to all the powerful linear algebra built into MATLAB, it can also function as basic calculator. You can use MATLAB Mobile to calculate final prices, how much it will cost to drive across town to save an additional $10 on the same item, etc.
3. Winning the football pool
With a little matrix manipulation and pre-computed probabilities, we can find out which boxes in a standard football pool have the best odds of winning. This is for the kind where you choose a square representing the last digit of the two teams’ scores. Thanks to the data from http://www.sabernomics.com/sabernomics/index.php/2005/01/squares-for-squares/, we can figure which square has the best odds:
Here’s the code if you want to cut & paste. Special thanks to Ned Gulley for inspiring this one.
prob = [1.7100 1.4800 0.5600 3.2100 2.0400 0.7200 1.5400 3.8000 0.9500 0.7400; ...
1.4800 0.8500 0.3300 1.0000 2.2300 0.2400 0.9500 1.9300 1.3500 0.5600;...
0.5600 0.3300 0.0400 0.5400 0.6500 0.3300 0.3500 0.4600 0.2200 0.3200;...
3.2100 1.0000 0.5400 1.1900 1.4500 0.5200 1.6300 1.9300 0.6100 0.7200;...
2.0400 2.2300 0.6500 1.4500 1.5900 0.5000 0.8200 3.7100 0.7200 0.6700;...
0.7200 0.2400 0.3300 0.5200 0.5000 0.1900 0.2200 0.7600 0.6900 0.2400;...
1.5400 0.9500 0.3500 1.6300 0.8200 0.2200 0.5600 0.8900 0.4800 0.6900;...
3.8000 1.9300 0.4600 1.9300 3.7100 0.7600 0.8900 1.9300 0.8300 0.8000;...
0.9500 1.3500 0.2200 0.6100 0.7200 0.6900 0.4800 0.8300 0.4100 0.3000;...
0.7400 0.5600 0.3200 0.7200 0.6700 0.2400 0.6900 0.8000 0.3000 0.1900];
[~,IX] = sort(prob(:),'descend');
[row,col]=ind2sub(size(prob),IX);
bestscores = horzcat(row-1,col-1)
4. A Reason To Be Thankful
Some families’ tradition includes everyone stating a reason to be thankful. In addition to a thoughtful and inspired answer, why not throw out a joke one as well. The why function is always good for coming up with an answer on the spot.
Have a safe and happy Thanksgiving.
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:55 UTC |
Posted in MATLAB Mobile |
Permalink |
3 Comments »
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 »
|
Recent Comments