Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
commBCHEncoder/commBCHDecoder

Subject: commBCHEncoder/commBCHDecoder

From: Timothy Koh

Date: 6 Mar, 2013 14:03:05

Message: 1 of 7

hi

i am facing some problem encoding a 480x640 image with commBCHEncoder.

i manage to convert the image into matrix using imread where i will get <480x640x3 unit8>.

Next i use B=(A(:,:,1)); where A is my image is matrix.

C=reshape(B,[],1);
D=dec2bin(C);
E=D';
F=reshape(E,[],1);

The result i get is <2457600x1 char>

I am not able to encode <2457600x1 char> and get an error:

Error using comm.BCHEncoder/step
Inputs must be either numeric or logical variables or fi objects.

Sorry i am kind of new to this.
Hope for help.

Regards
timothy

Subject: commBCHEncoder/commBCHDecoder

From: Steven_Lord

Date: 6 Mar, 2013 14:15:53

Message: 2 of 7



"Timothy Koh" <timothy_koh87@hotmail.com> wrote in message
news:kh7iap$di3$1@newscl01ah.mathworks.com...
> hi
>
> i am facing some problem encoding a 480x640 image with commBCHEncoder.
> i manage to convert the image into matrix using imread where i will get
> <480x640x3 unit8>.
> Next i use B=(A(:,:,1)); where A is my image is matrix.
> C=reshape(B,[],1);
> D=dec2bin(C);

http://www.mathworks.com/help/matlab/ref/dec2bin.html

"str = dec2bin(d) binary representation of d as a string."

If you want D to contain the numbers 0 and 1 instead of the characters '0'
and '1' then use either:

D = D - '0';
% or
D = (D == '1');

Since the error message indicates that either numeric or logical variables
are acceptable, either of these should work.

*snip*

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Subject: commBCHEncoder/commBCHDecoder

From: Timothy Koh

Date: 6 Mar, 2013 15:01:18

Message: 3 of 7

"Steven_Lord" <slord@mathworks.com> wrote in message <kh7j2o$g8v$1@newscl01ah.mathworks.com>...
>
>
> "Timothy Koh" <timothy_koh87@hotmail.com> wrote in message
> news:kh7iap$di3$1@newscl01ah.mathworks.com...
> > hi
> >
> > i am facing some problem encoding a 480x640 image with commBCHEncoder.
> > i manage to convert the image into matrix using imread where i will get
> > <480x640x3 unit8>.
> > Next i use B=(A(:,:,1)); where A is my image is matrix.
> > C=reshape(B,[],1);
> > D=dec2bin(C);
>
> http://www.mathworks.com/help/matlab/ref/dec2bin.html
>
> "str = dec2bin(d) binary representation of d as a string."
>
> If you want D to contain the numbers 0 and 1 instead of the characters '0'
> and '1' then use either:
>
> D = D - '0';
> % or
> D = (D == '1');
>
> Since the error message indicates that either numeric or logical variables
> are acceptable, either of these should work.
>
> *snip*
>
> --
> Steve Lord
> slord@mathworks.com
> To contact Technical Support use the Contact Us link on
> http://www.mathworks.com

Hi Steve Lord

Thank you so much your help. I wondering if you know what N and K value should i use if my data is <2457600x1 double>?

Regards
Timothy

Subject: commBCHEncoder/commBCHDecoder

From: Steven_Lord

Date: 6 Mar, 2013 15:10:18

Message: 4 of 7



"Timothy Koh" <timothy_koh87@hotmail.com> wrote in message
news:kh7lnu$pe1$1@newscl01ah.mathworks.com...
> "Steven_Lord" <slord@mathworks.com> wrote in message
> <kh7j2o$g8v$1@newscl01ah.mathworks.com>...

*snip*

> Thank you so much your help. I wondering if you know what N and K value
> should i use if my data is <2457600x1 double>?

I don't have any background in communications theory, so I don't know the
answer to your question.

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Subject: commBCHEncoder/commBCHDecoder

From: Timothy Koh

Date: 7 Mar, 2013 07:10:11

Message: 5 of 7

"Steven_Lord" <slord@mathworks.com> wrote in message <kh7j2o$g8v$1@newscl01ah.mathworks.com>...
>
>
> "Timothy Koh" <timothy_koh87@hotmail.com> wrote in message
> news:kh7iap$di3$1@newscl01ah.mathworks.com...
> > hi
> >
> > i am facing some problem encoding a 480x640 image with commBCHEncoder.
> > i manage to convert the image into matrix using imread where i will get
> > <480x640x3 unit8>.
> > Next i use B=(A(:,:,1)); where A is my image is matrix.
> > C=reshape(B,[],1);
> > D=dec2bin(C);
>
> http://www.mathworks.com/help/matlab/ref/dec2bin.html
>
> "str = dec2bin(d) binary representation of d as a string."
>
> If you want D to contain the numbers 0 and 1 instead of the characters '0'
> and '1' then use either:
>
> D = D - '0';
> % or
> D = (D == '1');
>
> Since the error message indicates that either numeric or logical variables
> are acceptable, either of these should work.
>
> *snip*
>
> --
> Steve Lord
> slord@mathworks.com
> To contact Technical Support use the Contact Us link on
> http://www.mathworks.com

Hi Steve Lord

Thank you so much your help. I wondering if you know what N and K value should i use if my data is <2457600x1 double>?

Regards
Timothy

Subject: commBCHEncoder/commBCHDecoder

From: Timothy Koh

Date: 11 Mar, 2013 07:03:17

Message: 6 of 7

"Timothy Koh" <timothy_koh87@hotmail.com> wrote in message <kh7lnu$pe1$1@newscl01ah.mathworks.com>...
> "Steven_Lord" <slord@mathworks.com> wrote in message <kh7j2o$g8v$1@newscl01ah.mathworks.com>...
> >
> >
> > "Timothy Koh" <timothy_koh87@hotmail.com> wrote in message
> > news:kh7iap$di3$1@newscl01ah.mathworks.com...
> > > hi
> > >
> > > i am facing some problem encoding a 480x640 image with commBCHEncoder.
> > > i manage to convert the image into matrix using imread where i will get
> > > <480x640x3 unit8>.
> > > Next i use B=(A(:,:,1)); where A is my image is matrix.
> > > C=reshape(B,[],1);
> > > D=dec2bin(C);
> >
> > http://www.mathworks.com/help/matlab/ref/dec2bin.html
> >
> > "str = dec2bin(d) binary representation of d as a string."
> >
> > If you want D to contain the numbers 0 and 1 instead of the characters '0'
> > and '1' then use either:
> >
> > D = D - '0';
> > % or
> > D = (D == '1');
> >
> > Since the error message indicates that either numeric or logical variables
> > are acceptable, either of these should work.
> >
> > *snip*
> >
> > --
> > Steve Lord
> > slord@mathworks.com
> > To contact Technical Support use the Contact Us link on
> > http://www.mathworks.com
>
> Hi Steve Lord
>
> Thank you so much your help. I wondering if you know what N and K value should i use if my data is <2457600x1 double>?
>
> Regards
> Timothy

Hi Steve

I used D = D - '0'; to convert from char to double.
What should i do to revert back from double to char?

Subject: commBCHEncoder/commBCHDecoder

From: Steven_Lord

Date: 11 Mar, 2013 13:38:03

Message: 7 of 7



"Timothy Koh" <timothy_koh87@hotmail.com> wrote in message
news:khjvjl$a4a$1@newscl01ah.mathworks.com...
> "Timothy Koh" <timothy_koh87@hotmail.com> wrote in message
> <kh7lnu$pe1$1@newscl01ah.mathworks.com>...
>> "Steven_Lord" <slord@mathworks.com> wrote in message
>> <kh7j2o$g8v$1@newscl01ah.mathworks.com>...

*snip*

> I used D = D - '0'; to convert from char to double. What should i do to
> revert back from double to char?

D = D + '0';
SPRINTF
NUM2STR

Any of these should work.

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us