<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/169688</link>
    <title>MATLAB Central Newsreader - code representation</title>
    <description>Feed for thread: code representation</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Wed, 21 May 2008 16:32:02 -0400</pubDate>
      <title>code representation</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/169688#433366</link>
      <author>ahmed</author>
      <description>hi &lt;br&gt;
if i have a signal (look like a sawtooth)i want to take &lt;br&gt;
the maximum values in this vector and from them to &lt;br&gt;
construct a binary code which represent this signal. can &lt;br&gt;
one tell me how to do this. </description>
    </item>
    <item>
      <pubDate>Wed, 21 May 2008 17:10:37 -0400</pubDate>
      <title>Re: code representation</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/169688#433372</link>
      <author>roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)</author>
      <description>In article &amp;lt;g11iq2$rak$1@fred.mathworks.com&amp;gt;,&lt;br&gt;
Ahmed  &amp;lt;mogwari2000@yahoo.com&amp;gt; wrote:&lt;br&gt;
&lt;br&gt;
&amp;gt;if i have a signal (look like a sawtooth)i want to take &lt;br&gt;
&amp;gt;the maximum values in this vector and from them to &lt;br&gt;
&amp;gt;construct a binary code which represent this signal. can &lt;br&gt;
&amp;gt;one tell me how to do this. &lt;br&gt;
&lt;br&gt;
&lt;br&gt;
One way:&lt;br&gt;
&lt;br&gt;
binarycode = (abs(signal - max(signal)) &amp;lt; tolerance);&lt;br&gt;
&lt;br&gt;
for an appropriately chosen tolerance to take into account that&lt;br&gt;
there might be a small bit of round-off in the calculation of&lt;br&gt;
the signal value at peaks.&lt;br&gt;
&lt;br&gt;
The result is a single-bit local vector that is 1 at peaks and&lt;br&gt;
0 elsewhere.&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
Other binary codes:&lt;br&gt;
&lt;br&gt;
sigmin = min(signal);&lt;br&gt;
sigmax = max(signal);&lt;br&gt;
bits = 3;&lt;br&gt;
binarycode = bin2dec( ceil(eps + 2^bits * (signal - sigmin) / (sigmax - sigmin)) - 1, bits);&lt;br&gt;
&lt;br&gt;
The result is an array, length(signal) x bits, of characters that are&lt;br&gt;
'0' or '1'. A number of people refer to this text representation of&lt;br&gt;
binary as a &quot;binary stream&quot; -- which I don't think is sufficiently&lt;br&gt;
correct, but using the phrase does give you an idea of what kind of&lt;br&gt;
output there would be. &lt;br&gt;
&lt;br&gt;
Each row would represent one sample point, and if one were to&lt;br&gt;
interpret the number in that row as binary, it would be which&lt;br&gt;
quartile or octile or hexadectile (or whatever the name is according&lt;br&gt;
to the number of bits you choose) the signal at that point was of&lt;br&gt;
the maximum signal range. For example, '000' would indicate that&lt;br&gt;
the sample was in the bottom 1/8th of the signal range, and '110' would&lt;br&gt;
indicate that the sample was in the second-from-the-top 8'th of&lt;br&gt;
the signal range.&lt;br&gt;
&lt;br&gt;
This is effectively a quantization of the signal into binary, &lt;br&gt;
and if you keep the signal minimum and maximum values, then&lt;br&gt;
you can use these values to recreate the signal to any desired&lt;br&gt;
binary degree of accuracy (by using more bits.) With the binary codes&lt;br&gt;
in hand, you could also run compression algorithms if you had some&lt;br&gt;
reason to do so.&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
But this is just speculation: your question is not at all&lt;br&gt;
descriptive of what kind of &quot;binary codes&quot; you want to&lt;br&gt;
construct to represent the signal. Like, are you looking for&lt;br&gt;
the signal to be represented by spokesbits, or is the signal&lt;br&gt;
looking for a good two-bit shyster to negotiate &quot;appearance&quot; fees,&lt;br&gt;
or is the signal looking for a good tax accountant because when&lt;br&gt;
it comes to tax dodges, every little bit helps?&lt;br&gt;
-- &lt;br&gt;
This is a Usenet signature block. Please do not quote it when replying&lt;br&gt;
to one of my postings.&lt;br&gt;
&lt;a href=&quot;http://en.wikipedia.org/wiki/Signature_block&quot;&gt;http://en.wikipedia.org/wiki/Signature_block&lt;/a&gt;</description>
    </item>
    <item>
      <pubDate>Wed, 21 May 2008 21:49:03 -0400</pubDate>
      <title>Re: code representation</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/169688#433411</link>
      <author>ahmed</author>
      <description>thanks for guide and help.&lt;br&gt;
&lt;br&gt;
i well try to implement the second way.&lt;br&gt;
&lt;br&gt;
i notice in the place of bin2dec i well use dec2bin is it &lt;br&gt;
right?&lt;br&gt;
&lt;br&gt;
is it possible to implement it to a matrix in the place of &lt;br&gt;
a vector.&lt;br&gt;
&lt;br&gt;
if i like to go a head way and to make a compression to &lt;br&gt;
the resultant array . can you give an idea.</description>
    </item>
    <item>
      <pubDate>Wed, 21 May 2008 22:37:48 -0400</pubDate>
      <title>Re: code representation</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/169688#433421</link>
      <author>roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)</author>
      <description>In article &amp;lt;g125cf$5mh$1@fred.mathworks.com&amp;gt;,&lt;br&gt;
Ahmed  &amp;lt;mogwari2000@yahoo.com&amp;gt; wrote:&lt;br&gt;
&lt;br&gt;
&amp;gt;i well try to implement the second way.&lt;br&gt;
&lt;br&gt;
&amp;gt;i notice in the place of bin2dec i well use dec2bin is it &lt;br&gt;
&amp;gt;right?&lt;br&gt;
&lt;br&gt;
Ah yes, I did get that flipped around.&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&amp;gt;is it possible to implement it to a matrix in the place of &lt;br&gt;
&amp;gt;a vector.&lt;br&gt;
&lt;br&gt;
Yes, but the output of bin2dec will still end up being&lt;br&gt;
a character vector whose number of columns (width) is the same as&lt;br&gt;
the number of bits. The result is the same as if you had converted&lt;br&gt;
the matrix to a vector:&lt;br&gt;
&lt;br&gt;
bin2dec(somematrix,3)  is the same as  bin2dec(somematrix(:),3)&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&amp;gt;if i like to go a head way and to make a compression to &lt;br&gt;
&amp;gt;the resultant array . can you give an idea.&lt;br&gt;
&lt;br&gt;
Well, if I were planning compression, then I would not use&lt;br&gt;
exactly the approach I outlined. You indicated that you have&lt;br&gt;
a saw-tooth type wave, which hints that is not particularily&lt;br&gt;
discontinuous. If you take the difference between successive samples&lt;br&gt;
using diff() then especially if you have sampled at a much higher&lt;br&gt;
frequency than the sawtooth frequency, the differences in&lt;br&gt;
the percentile (or whatever) of successive samples will tend to&lt;br&gt;
be small. You can histogram the changes to get counts for each&lt;br&gt;
difference, and thus probabilities of each difference. Probabilitie&lt;br&gt;
in hand, you can built a variable-length representation, such as using&lt;br&gt;
the well-known Huffman algorithm. Then just run through the difference&lt;br&gt;
array, outputting the variable-length code corresponding to the&lt;br&gt;
difference, and the output will be a compressed string representation&lt;br&gt;
of the signal. Then by knowing the signal maximum and minimum&lt;br&gt;
and the resolution of the encoding, and the variable-length&lt;br&gt;
encoding table, the process could be reversed.&lt;br&gt;
&lt;br&gt;
That is, if what you are looking for is to have some fun and&lt;br&gt;
learn something building a signal compressor. If you were applying&lt;br&gt;
this to real signals that you had a lot of, then more complex&lt;br&gt;
predictive methods and more compact encodings might become important&lt;br&gt;
in order to achieve the maximum compression while still maintaining&lt;br&gt;
key signal properties. For example with EKG signals, the main signals&lt;br&gt;
are relatively predictable, but preserving the shapes of oddities in&lt;br&gt;
the signal can be *very* important: smoothing out an EKG signal&lt;br&gt;
to remove some inconvenient bumps is *not* acceptable. But there are&lt;br&gt;
a lot of other signal types where a random spike is mostly just noise&lt;br&gt;
to be removed; you use differenc compressions for those cases than for EKG.&lt;br&gt;
&lt;br&gt;
-- &lt;br&gt;
'Roberson' is my family name; my given name is 'Walter'.</description>
    </item>
    <item>
      <pubDate>Thu, 12 Jun 2008 22:56:02 -0400</pubDate>
      <title>Re: code representation</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/169688#437224</link>
      <author>ahmed</author>
      <description>&lt;br&gt;
if i have signal like this &lt;br&gt;
a =&lt;br&gt;
[0.0003,0.0103,0.0108,0.0113,0.0148,0.0188,0.0180,0.0186,0.&lt;br&gt;
0195,0.0176,0.0189,0.0189,0.0198,0.0197,0.0204,0.0192,0.020&lt;br&gt;
1,0.0193,&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br&gt;
0.0184,0.0201,0.0212,0.0309,0.0442,0.0447,0.0479,0.0337,0.0&lt;br&gt;
426,0.0500,0.0481,0.0488,0.0481,0.0491,0.0391,0.0479,0.0577&lt;br&gt;
,0.0552,&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br&gt;
0.0563,0.0590,0.0622,0.0581,0.0610,0.0541,0.0293,0.0307,0.0&lt;br&gt;
448,0.0519,0.0784,0.1600,0.1951,0.1914,0.2036,0.1865,0.0719&lt;br&gt;
,0.0434,&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br&gt;
0.0543,0.0485,0.0435,0.0462,0.0506,0.0568,0.0646,0.0687,0.0&lt;br&gt;
761,0.0788,0.0457,0.0417,0.0290,0.0326,0.0711,0.0938,0.1112&lt;br&gt;
,0.0715,&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br&gt;
0.0526,0.0472,0.0437,0.0558,0.0627,0.0639,.0717,0.0716,0.07&lt;br&gt;
38,0.0628,0.0495,0.0450,0.0361,0.0340,0.0378,0.0372,0.0350,&lt;br&gt;
0.0364,0.0361,0.0403,0.0958,&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br&gt;
0.0861,0.0308,0.0270,0.0320,0.0278,0.0271,0.0287,0.0254,0.0&lt;br&gt;
257,0.0260,0.0270,0.0288,0.0283,0.0262,0.0257,0.0341,0.0449&lt;br&gt;
,0.0877,0.0790,0.0112,0.0094,0.0094,0.0094,0.0074,&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br&gt;
0.0099,0.0108,0.0099,0.0100,0.0094,0.0081,0.0081,0.0069,0.0&lt;br&gt;
067,0.0061,0.0029]&lt;br&gt;
&lt;br&gt;
you can plot it to see the shape: plot(a);&lt;br&gt;
&lt;br&gt;
i like to take just into account the extreme points (peaks &lt;br&gt;
and valleys) in this signal, &lt;br&gt;
i dont like to consider ripples points in the signal &lt;br&gt;
&lt;br&gt;
how can i do that?</description>
    </item>
  </channel>
</rss>

