Doug’s MATLAB Video Tutorials
July 2nd, 2009
Advanced: loading files using their names for variable names
In this short video we will show how to bring text files into MATLAB and use the original file name as the variable name. Actually, the file name will be used as a field name in a structure.
Some people would use the EVAL statement or ASSIGNIN to do this, however doing so would disallow the JIT accelerator from speeding the code up as much as it could. The skills taught in this video are related to the ones in these videos:
Processing files in a directory with MATLAB
Dynamic field name usage in MATLAB
16:22 UTC |
Posted in Format: Video, Level: Advanced |
Permalink |
1 Comment »
June 25th, 2009
HandleVisibility property to make GUIs visible in handles hierarchy
A MATLAB user recently asked me why they could not find the handle to their GUI as a child of the root.
get(0, ‘children’)
The reason is they needed to change the handleVisibilty property of the GUI. This video shows how that is done.
21:17 UTC |
Posted in Level: Advanced, Topic: GUI or GUIDE |
Permalink |
No Comments »
June 17th, 2009
Puzzler: Find four-connected component to element 1 of 2-d matrix
This week, I was going to make a great video on recursion to solve a fun little puzzle. However, my code runs too slow. Before my recursive solution to the larger puzzle is practical, I need to clean out this bottleneck in the solver.
I have found the bottleneck to be here (taken out of context for clarity):
sizeBoardEdge = 6;
numColors = 6;
tic
for i = 1:15000
%optimize contents of loop
%currently this take 3 seconds, would like to do significantly better
board = round(rand(sizeBoardEdge)*numColors);
oldColor = board(1,1);
%
connectedComponents = bwconncomp((board == oldColor),4);
vi = connectedComponents.PixelIdxList{1};
end
toc
Notice that I only want the indices of the pixels that are in the ‘four connected pool’ of pixels of the same value as the pixel in the upper left corner.
The benchmark to beat is 15000 calls in 3 seconds.
Here is a graphical example of what this should do.
My code uses the Image Processing Toolbox. I am hoping a dedicated function could be optimized to run faster than BWCONNCOMP since I am only using a small amount of the information that this function calculates.
The best solution to this by next week will get a MATLAB t-shirt, if it can cut the time on my machine by at least one half.
16:24 UTC |
Posted in Level: Advanced, Topic: Puzzler |
Permalink |
37 Comments »
June 12th, 2009
Using HIST and BAR to customize your histograms
I recently had a question come in via e-mail where this MATLAB user wanted to be able to change the look of her histogram. The key to this problem was using HIST to generate the binning data and then use the more flexible BAR to make the bar chart look exactly as she wished. If HIST is used without a left hand side argument, then the function will make a plot using some default choices. If you want more control over the graph, you will have to use the flexibility of BAR to do that.
17:39 UTC |
Posted in Format: Video, Level: Basic |
Permalink |
No Comments »
June 5th, 2009
Building a GUI to read, modify and write an Excel file. 4/4
This is the fourth in a series of videos that will go through the process of planing and implementation of a simple GUI. Realistically, I would not plan out a GUI this simple, but the idea is to show what my planning process is on a simple example. The purpose of this GUI is to:
- Select an Excel file and read it into the MATLAB workspace
- Modify the data that came from the file. In this case by multiplying by a scalar
- Write the modified data into an Excel file with a name derived from the original filename
The first video is all about the planning of the GUI.
The second video creates the low-level functions needed to implement the functionality
The third video creates a single m-file that runs the low-level functions
The final video implements the simple GUI discussed here, calling the functions created above.
20:35 UTC |
Posted in Format: Video, Level: Advanced, Topic: GUI or GUIDE |
Permalink |
2 Comments »
May 29th, 2009
Building a GUI to read, modify and write an Excel file. 3/4
This is the third in a series of videos that will go through the process of planing and implementation of a simple GUI. Realistically, I would not plan out a GUI this simple, but the idea is to show what my planning process is on a simple example. The purpose of this GUI is to:
- Select an Excel file and read it into the MATLAB workspace
- Modify the data that came from the file. In this case by multiplying by a scalar
- Write the modified data into an Excel file with a name derived from the original filename
The first video is all about the planning of the GUI.
The second video creates the low-level functions needed to implement the functionality
The third video creates a single MATLAB file that runs the low-level functions
The final video implements the simple GUI discussed here, calling the functions created above.
18:06 UTC |
Posted in Format: Video, Level: Advanced, Topic: Excel, Topic: GUI or GUIDE |
Permalink |
No Comments »
May 22nd, 2009
Building a GUI to read, modify and write an Excel file. 2/4
This is the second in a series of videos that will go through the process of planing and implementation of a simple GUI. Realistically, I would not plan out a GUI this simple, but the idea is to show what my planning process is on a simple example. The purpose of this GUI is to:
- Select an Excel file and read it into the MATLAB workspace
- Modify the data that came from the file. In this case by multiplying by a scalar
- Write the modified data into an Excel file with a name derived from the original filename
The first video is all about the planning of the GUI.
The second video creates the low-level functions needed for implement the functionality
The third video creates a single m-file that runs the low-level functions
The final video implements the simple GUI discussed here, calling the functions created above.
17:38 UTC |
Posted in Format: Video, Level: Advanced, Topic: Excel, Topic: GUI or GUIDE |
Permalink |
No Comments »
May 15th, 2009
Building a GUI to read, modify and write an Excel file. 1/4
Internet explorer users: Please follow the permalink at the bottom of this post to see the correct video… We are working on this! Sorry!
This is the first in a series of videos that will go through the process of planing and implementation of a simple GUI. Realistically, I would not plan out a GUI this simple, but the idea is to show what my planning process is on a simple example. The purpose of this GUI is to:
- Select and Excel file and read it into the MATLAB workspace
- Modify the data that came from the file. In this case by multiplying by a scalar
- Write the modified data into an Excel file with a name derived from the original filename
The first video is all about the planning of the GUI.
The second video creates the low-level functions needed to implement the functionality
The third video creates a single m-file that runs the low-level functions
The final video implements the simple GUI discussed here, calling the functions created above.
15:49 UTC |
Posted in Format: Video, Level: Basic, Topic: Excel, Topic: GUI or GUIDE |
Permalink |
2 Comments »
May 8th, 2009
Implementing a simple circular buffer
Internet explorer users: Please follow the permalink at the bottom of this post to see the correct video… We are working on this! Sorry!
I frequent StackOverflow.com answering MATLAB question. Here is the answer to one that recently went by.
In this three minute video I show how to implement a circular buffer for keeping a limited time history. This is useful for keeping only the history that you need for a variable. A strip chart could be plotted from one of these.
18:16 UTC |
Posted in Format: Video, Level: Basic |
Permalink |
3 Comments »
May 1st, 2009
Quick productivity tip in 2009a
One of the best things about working at The MathWorks is seeing my suggestions implemented in the product. I like seeing a feature and knowing that I was one (possibly one of many) to request the feature.
This is a simple little feature added in 2009a: middle click on a tab in the editor to close it. Because I am a FireFox user, I had learned that technique for closing tabs in the browser. I just expected it to work in MATLAB. Now it does!
Do you have something you would like to see added in MATLAB? This blog entry from the Desktop team shows you how.
17:05 UTC |
Posted in Uncategorized |
Permalink |
No Comments »
|
Recent Comments