LAT Hologramm-Software 2.0
Loading...
Searching...
No Matches
gc2dec.m
Go to the documentation of this file.
1function dec = gc2dec(gra)
2
3% Description: This function converts a gray coded string to its equivalent
4% decimal representation.
6% Call Syntax: [output_variables] = function_name(input_variables)
7%
8% Input Arguments:
9% Name: gra
10% Type: matrix
11% Description: each row represents a gray coded string
12
13
14% Output Arguments:
15% Name: dec
16% Type: vector
17% Description: decimal numbers in column vector form of size, size(gra,1) x 1
18%
19% Creation Date: 08/07/2005
20% Author : Arjun Srinivasan Rangamani
21
22%*************************************************************************
23
24%------------------
25% Check valid input
26%------------------
27if (nargin ~= 1)
28 error('Error (gc2dec): must have only 1 input argument.');
29end
30
31
32s1 = size(gra,1);%num of rows in input vector
33s2 = size(gra,2);%num of columns in the input vector
34dec = zeros(s1,1);%size of the o/p decimal number sequence
35bin = char(zeros(1,s2));
36
37
38%gray to binary conversion
39for j1 = 1:1:s1
40 for j2 = s2:-1:2
41 temp = mod(sum(gra(j1,1:j2-1)),2);
42 if temp == 1
43 bin(j2) = num2str(1 - gra(j1,j2));
44 else
45 bin(j2) = num2str(gra(j1,j2));
46 end
47 end
48 bin(1) = num2str(gra(j1,1));
49 dec(j1,1) = bin2dec(bin);
50end
51
52
function gc2dec(in gra)