Loren on the Art of MATLAB

Turn ideas into MATLAB

Results for: Indexing

Rearranging Data 20

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

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 >>

Deal or No Deal 21

This post continues in the theme from my last post, where people routinely come to me on a topic. Today I want to distinguish
between indexed assignment, where you can take advantage of scalar expansion, and assignment to several output arrays, often
arising from a comma-separated list from cell or struct arrays.... read more >>

A Way to Account for Missing Data 15

MATLAB has the concept of Not-a-Number, also known as NaN for quite some time. Following the IEEE 754 Standard for Binary Floating-Point Arithmetic, some floating point calculations result in NaN, for example, 0/0. You can also use them as placeholders in numeric arrays, for example to denote missing data. If... read more >>

Reversal of a sort 24

We can sometimes be motivated to reverse things in Boston. And I occasionally get asked how to reverse the sort direction from MATLAB. So instead of sorting A and then having B follow the new order, let's undo a sorting operation, and in a way that multiple vectors... read more >>