Loren on the Art of MATLAB

Results for: Indexing

Logical Indexing – Multiple Conditions 22

Posted by Loren Shure,

I've talked about logical indexing before in some of the linked posts, but recent work makes me want to show it off again. One of the nice things about logical indexing is that it is very easy and natural to combine the results of different conditions to select items based on multiple criteria.... read more >>

Partitioning a Vector 9

Posted by Loren Shure,

Recently on the MATLAB newsgroup, there was a thread asking how to split up a vector into pieces which were each monotonically increasing by the value 1. The post got several answers which I did not read first. Here's my thinking.... read more >>

Meet the Neighbors 13

Posted by Loren Shure,

Meet the Neighbors  Some calculations in MATLAB, including, for example, calculating local means or finite differences, or applying some other filter locally, operate on neighboring matrix elements. Doing so in an efficient manner is easy... read more >>

Indexing – Mixing It Up 16

Posted by Loren Shure,

Indexing – Mixing It Up  I've written a bunch of posts related to indexing, but I still haven't showed all the flexibility allowed. Today I'm going to add a variant to the list. Contents ... read more >>

Rearranging Data 20

Posted by Loren Shure,

Rearranging Data  I can think of a lot of functions that rearrange data in MATLAB. I've long suspected that not all of these are well-known, though some are clearly daily tools. Maybe it's... read more >>

Unique Values Without Rearrangement 4

Posted by Loren Shure,

Unique Values Without Rearrangement  In MATLAB, the simplest form of the function unique returns the unique values contained in a numeric vector, with the results sorted. This is often acceptable, but sometimes a user prefers the... read more >>

Coordinating Zero Removals from Multiple Arrays 13

Posted by Loren Shure,

Coordinating Zero Removals from Multiple Arrays  I've fielded some questions recently about how to coordinate multiple arrays changing simultaneously. One example is removing elements for two arrays in the case where either array holds a zero for the... read more >>

Vectorizing the Notion of Colon (:) 14

Posted by Loren Shure,

Vectorizing the Notion of Colon (:)  The other day, one of my MathWorks buddies, Peter, asked me if I knew any tricks for vectorizing the notion of the colon (:) operator. For me, this sort of inquiry sometimes has an effect similar to waving a flag in... read more >>

Timing Extraction of Parts of an Array 10

Posted by Loren Shure,

Timing Extraction of Parts of an Array  In Sarah's blog, Dan asked about speed of removing elements. There are a number of ways of deleting elements in MATLAB. So, what's the "best" way? ... read more >>

Acting on Specific Elements in a Matrix 32

Posted by Loren Shure,

Acting on Specific Elements in a Matrix  Using MATLAB, there are several ways to identify elements from an array for which you wish to perform some action. Depending on how you've chosen the elements, you may either have the list... read more >>

These postings are the author's and don't necessarily represent the opinions of MathWorks.