Loren on the Art of MATLAB

Turn ideas into MATLAB

Results for: Indexing

Get Smart, Be Logical! 1

Posted by Loren Shure,

Recently a customer asked me an interesting question about a good way to compute something. Before I sat down to tackle it, I happened to mention the problem to my pal, Sean. And he quickly answered, "max logical". It took me just a moment to realize what he was saying, and it is the answer to the problem. But when I heard it, I heard a person's name "Max Logical", and though I didn't know who that was, I immediately thought of Maxwell Smart, from the 60s tv comedy in the US, called "Get Smart".... read more >>

Indexing with Curly Braces 3

Posted by Loren Shure,

I have talked about indexing a bunch of times in the past, including my last post. Recently I have visited quite a few customers who still get tripped up a bit sometimes. So I thought I'd try again.... read more >>

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,

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 under the right conditions ... read more >>

Indexing – Mixing It Up 16

Posted by Loren Shure,

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. ... read more >>

Rearranging Data 20

Posted by Loren Shure,

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 time to be sure they get exposure. ... read more >>

Unique Values Without Rearrangement 4

Posted by Loren Shure,

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 results in the order originally found in the data. ... read more >>