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 22:37:48 +0000 (UTC)
Organization: National Research Council Canada - Conseil national de rechereches Canada
Lines: 56
Message-ID: <g1287s$dlf$1@canopus.cc.umanitoba.ca>
References: <g11iq2$rak$1@fred.mathworks.com> <g11l2d$g0m$1@canopus.cc.umanitoba.ca> <g125cf$5mh$1@fred.mathworks.com>
NNTP-Posting-Host: origin.ibd.nrc.ca
X-Trace: canopus.cc.umanitoba.ca 1211409468 13999 192.70.172.160 (21 May 2008 22:37:48 GMT)
X-Complaints-To: abuse@cc.umanitoba.ca
NNTP-Posting-Date: Wed, 21 May 2008 22:37:48 +0000 (UTC)
Originator: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Xref: news.mathworks.com comp.soft-sys.matlab:469767



In article <g125cf$5mh$1@fred.mathworks.com>,
Ahmed  <mogwari2000@yahoo.com> wrote:

>i well try to implement the second way.

>i notice in the place of bin2dec i well use dec2bin is it 
>right?

Ah yes, I did get that flipped around.


>is it possible to implement it to a matrix in the place of 
>a vector.

Yes, but the output of bin2dec will still end up being
a character vector whose number of columns (width) is the same as
the number of bits. The result is the same as if you had converted
the matrix to a vector:

bin2dec(somematrix,3)  is the same as  bin2dec(somematrix(:),3)


>if i like to go a head way and to make a compression to 
>the resultant array . can you give an idea.

Well, if I were planning compression, then I would not use
exactly the approach I outlined. You indicated that you have
a saw-tooth type wave, which hints that is not particularily
discontinuous. If you take the difference between successive samples
using diff() then especially if you have sampled at a much higher
frequency than the sawtooth frequency, the differences in
the percentile (or whatever) of successive samples will tend to
be small. You can histogram the changes to get counts for each
difference, and thus probabilities of each difference. Probabilitie
in hand, you can built a variable-length representation, such as using
the well-known Huffman algorithm. Then just run through the difference
array, outputting the variable-length code corresponding to the
difference, and the output will be a compressed string representation
of the signal. Then by knowing the signal maximum and minimum
and the resolution of the encoding, and the variable-length
encoding table, the process could be reversed.

That is, if what you are looking for is to have some fun and
learn something building a signal compressor. If you were applying
this to real signals that you had a lot of, then more complex
predictive methods and more compact encodings might become important
in order to achieve the maximum compression while still maintaining
key signal properties. For example with EKG signals, the main signals
are relatively predictable, but preserving the shapes of oddities in
the signal can be *very* important: smoothing out an EKG signal
to remove some inconvenient bumps is *not* acceptable. But there are
a lot of other signal types where a random spike is mostly just noise
to be removed; you use differenc compressions for those cases than for EKG.

-- 
'Roberson' is my family name; my given name is 'Walter'.