I recently bought an ammeter on sale from Sears for $25 and started wandering around my apartment measuring the amount of power my electronics used.
Apparently, the “power” button on my LCD monitor only serves to turn the little LED on the front on and off: whether it’s in stand-by or “off”, it consumes about 2.5W. On, it consumes a whopping 32.5W, more than my laptop while in regular use.
For a while, I was tempted to get something like the Kill-a-watt just to see how much power I was using, but I found a cheap extension cord, sliced to separate the +, -, and ground combined with a clamp ammeter does the trick for the same price with a more versatile device to boot.
Other interesting appliances were the TV (7W “off”, 90W on), the microwave (1.5W off, lots and lots on), and the Roomba while charging (4W). Unlike my old Nokia charger that remained warm while plugged in, even without a phone, my Motorola charger doesn’t seem to consume power while the phone isn’t plugged in.

The Macbook Pro is awesome.

If I know you and promised to do something for you and haven’t yet, that’s why.

Scalar quantization, as Wikipedia puts it,
“is the process of approximating a continuous range of values (or a very large set of possible discrete values) by a relatively-small set of discrete symbols or integer values.”
Generally, the process involves mapping from an interval of numbers in the range to a single number in the domain. Because it is a process so heavily used in signal compression, it is useful to have a function to perform it at high speeds in MATLAB. The Communications Toolbox includes a quantiz function, which maps a vector of floats to a vector of integers given another vector of ranges, but being implemented as an m-file, it is slow.
However, the base toolbox (the one that has all of the general MATLAB tools), has the histc function. histc, given a data vector and a vector of bin edges, counts the number data elements in each bin. The lesser known second output of histc actually returns the bin number for each data element, the process of quantization.
For example, suppose we wanted to perform 3-bit uniform quantization for the numbers between 0 and 1, i.e., given a data vector x and evenly distributed bins between 0 and 1, we wanted to map each data value to an integer 0 through 7.
>> x = rand(1, 100); >> e = linspace(0, 1, 8); >> [n, idx] = histc(x, e);
The previous snippet yields each element of x mapped to a number 1 through 8 in idx (we may subtract 1 to get 3-bit numbers 0 through 7).
To approximate x using the bin edges (codebook) and quantization indices, we may:
>> y = e(idx);
If we had subtracted 1 from the idx, we would have to add it back in at this stage. The same procedure holds for any non-overlapping, ordered, quantization partitions, e.g., exponential, Lloyd-Max. For large data-sets, and reasonable size codebooks, the space savings are significant as is the performance of histc over quantiz.

Earlier, I complained that MATLAB’s Object Orientation was lacking and suggested an improvement. As it turns out, MATLAB already has an extremely similar mechanism to the one I suggested, but has not documented it. The mechanism has existed since at least 7.3 (R14.3), but has several changes in R2006b.
The simplest class definition is:
classdef myclass
<statement-1>
<statement-2>
.
.
.
<statement-N>
end
Generally, the statements inside of the class will be method and field declarations, but any valid MATLAB is valid within the class definition.
This syntax is new as of R2006b. In R2006a and R14.3, classdef must be replaced with class
As before, m-files with class definitions must be placed in directories named @classname For example, an m-file named myclass.m might define a class myclass by opening the file with classdef myclass, but to be recognized as a class, myclass.m must be in a directory called @myclass on the MATLAB path.
More information forthcoming.
More information forthcoming.
This OO API supports fine-grained access controls (public, private, protected) for both fields and methods. More information forthcoming.
This OO API simplifies inheritance. Suppose myclass should inherit from baseclass. When defining myclass, we write:
classdef myclass<baseclass
<statement-1>
<statement-2>
.
.
.
<statement-N>
end
The only change from the standard class definition is the addition of baseclass to the class definition line.
Like variables passed into and returned from functions, MATLAB implements lazy copy when assigning values to class fields. For example,
>> a = rand(1000); >> x = myclass(); >> y = myclass(); >> x.data = a; >> y.data = a;
This snippet requires enough memory to hold a, (plus some small overhead to hold the class data for x and y) but does not copy a unless a, x.data, y.data is modified. Hence the above snippet will require roughly only 8MB of memory rather than 24MB.
I am preparing longer documentation and will post it when complete. For longer examples, see the implementations of memmapfile and timeseries in MATLAB.
The structure of the above documentation is borrowed from the Python Tutorial’s chapter on classes.
