Practical example: Algorithm development for making colormaps
In a recent post, I mentioned LazyWeb It worked better than I expected. Matt posted some code that I requested that will highlight a line when you click on it. This works exactly as hoped. Thanks Matt, your MATLAB T-shirt has been shipped to thank you for your effort.
Ned thought this was great, so he posted a request for some code that makes colormaps.
I took up the challenge, mostly so that I could record how I went about developing an algorithm.
I broke this into two videos:
In this first video you will see:
- The colormaps that we are developing from a journal article
- The colormap applied to a MATLAB figure
- How to call the code to make the colormap
- Explaining the structure of a colormap in MATLAB
- Exploring colormaps in the colormap editor
- Plotting a colormap to understand its structure
- Creating the colormap creating subfunction
- Testing the subfunction
In this second video you will see:
- We review the colormaps that are to be made.
- Show the four expected calling syntaxes for the function
- Show how to use VARARGIN to make deal with different numbers of input arguments
- Show error catching
- Show different branches of code to be followed based on inputs
- Developing an algorithm with cell mode to test an algorithm
- Testing
- Documentation
This code was written live, so mistakes were made along the way. This gives you a realistic view of how a MATLAB expert deals with the inevitable errors that occur while programming.
The file that got created is useful on its own, so I have posted it here
Other videos have been gathered here:
https://blogs.mathworks.com/pick/category/video/
Practical example videos have been gathered here:
https://blogs.mathworks.com/pick/category/practical-example
评论
要发表评论,请点击 此处 登录到您的 MathWorks 帐户或创建一个新帐户。