Jiro's pick this week is INSERTROWS by Jos van der Geest.
This function does exactly what the name says: it inserts rows into a matrix. What makes this significant is that this seemingly
trivial task is not straightforward to do in MATLAB. I can easily take rows out of a matrix, but putting rows in is not trivial.
Let's say you have matrices mat1 and mat2:
As an added feature, this function also allows you to insert multiple rows into different locations of the original matrix.
For example, if you want to insert first row of mat2 after row 2 and the second row of mat2 after row 4:
Finally, I like how thorough the help and the examples are. Having good documentation greatly enhances the users' experiences,
and I'm always impressed with the completeness of Jos's submissions. This function falls into one of my favorite categories
- "Simple, but Useful Functions".
Comments
Here's a challenge for everyone. I've already asked people about their own "simple functions" in my previous blog post, but try to think about the codes that you are writing everyday, and see if you can start creating your own modular functions,
regardless of how trivial they may seem. You'll find that they will make your programs much more readable and manageable.
Then consider posting them to the File Exchange and let us know about your experiences here.
Comments
To leave a comment, please click here to sign in to your MathWorks Account or create a new one.