File Exchange Pick of the Week
September 1st, 2005
Flip Arrays
I love small, simple, useful functions. Many of my own submissions are not much more than one line of code (wopen, goto) that I use dozens of times a week. Duane Hanselman submitted a great one the other day. FLIPARRAY works just like FLIPUD and FLIPLR, except that it doesn’t require you to figure out if the input is a row or column vector first. It also extends nicely to support multidimensional arrays, preserving the array shape.
Duane received some grief over such a “simple” submission, including a nomination for removal. I couldn’t disagree more - I think submissions like this make the File Exchange great, and make MATLAB much more enjoyable to live with. The fact that it’s only one line of code tells me two things:
- MATLAB has a very compact, efficient language.
- Duane knows how to use it to his advantage.
I don’t know about you, but I’d much rather type:
>> x = fliparray(x)
than
>> x(:)=x(end:-1:1);
It takes less thought, is easier to type, and makes my code infinitely more readable. Thanks, Duane.
12:57 UTC |
Posted in Uncategorized |
Permalink |
You can follow any responses to this entry through the RSS 2.0 feed.
Both comments and pings are currently closed.
|
Recent Comments