Path: news.mathworks.com!newsfeed-00.mathworks.com!NNTP.WPI.EDU!elk.ncren.net!newsflash.concordia.ca!canopus.cc.umanitoba.ca!not-for-mail
From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Newsgroups: comp.soft-sys.matlab
Subject: Re: code representation
Date: Wed, 21 May 2008 17:10:37 +0000 (UTC)
Organization: National Research Council Canada - Conseil national de rechereches Canada
Lines: 62
Message-ID: <g11l2d$g0m$1@canopus.cc.umanitoba.ca>
References: <g11iq2$rak$1@fred.mathworks.com>
NNTP-Posting-Host: origin.ibd.nrc.ca
X-Trace: canopus.cc.umanitoba.ca 1211389837 16406 192.70.172.160 (21 May 2008 17:10:37 GMT)
X-Complaints-To: abuse@cc.umanitoba.ca
NNTP-Posting-Date: Wed, 21 May 2008 17:10:37 +0000 (UTC)
Originator: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Xref: news.mathworks.com comp.soft-sys.matlab:469718



In article <g11iq2$rak$1@fred.mathworks.com>,
Ahmed  <mogwari2000@yahoo.com> wrote:

>if i have a signal (look like a sawtooth)i want to take 
>the maximum values in this vector and from them to 
>construct a binary code which represent this signal. can 
>one tell me how to do this. 


One way:

binarycode = (abs(signal - max(signal)) < tolerance);

for an appropriately chosen tolerance to take into account that
there might be a small bit of round-off in the calculation of
the signal value at peaks.

The result is a single-bit local vector that is 1 at peaks and
0 elsewhere.


Other binary codes:

sigmin = min(signal);
sigmax = max(signal);
bits = 3;
binarycode = bin2dec( ceil(eps + 2^bits * (signal - sigmin) / (sigmax - sigmin)) - 1, bits);

The result is an array, length(signal) x bits, of characters that are
'0' or '1'. A number of people refer to this text representation of
binary as a "binary stream" -- which I don't think is sufficiently
correct, but using the phrase does give you an idea of what kind of
output there would be. 

Each row would represent one sample point, and if one were to
interpret the number in that row as binary, it would be which
quartile or octile or hexadectile (or whatever the name is according
to the number of bits you choose) the signal at that point was of
the maximum signal range. For example, '000' would indicate that
the sample was in the bottom 1/8th of the signal range, and '110' would
indicate that the sample was in the second-from-the-top 8'th of
the signal range.

This is effectively a quantization of the signal into binary, 
and if you keep the signal minimum and maximum values, then
you can use these values to recreate the signal to any desired
binary degree of accuracy (by using more bits.) With the binary codes
in hand, you could also run compression algorithms if you had some
reason to do so.


But this is just speculation: your question is not at all
descriptive of what kind of "binary codes" you want to
construct to represent the signal. Like, are you looking for
the signal to be represented by spokesbits, or is the signal
looking for a good two-bit shyster to negotiate "appearance" fees,
or is the signal looking for a good tax accountant because when
it comes to tax dodges, every little bit helps?
-- 
This is a Usenet signature block. Please do not quote it when replying
to one of my postings.
http://en.wikipedia.org/wiki/Signature_block