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:
convert logical to string

Subject: convert logical to string

From: maan

Date: 4 Mar, 2012 23:43:15

Message: 1 of 7

A=0 1 1 1 0 1 1 0 ;
A is of type logical
i need to convert it to a string , so A will equal 'v'

Subject: convert logical to string

From: maan

Date: 4 Mar, 2012 23:49:13

Message: 2 of 7

"maan " <maan_waysi@yahoo.com> wrote in message <jj0umi$pi4$1@newscl01ah.mathworks.com>...
> A=0 1 1 1 0 1 1 0 ;
> A is of type logical
> i need to convert it to a string , so A will equal 'v'


i use matlab R2009a

Subject: convert logical to string

From: Roger Stafford

Date: 4 Mar, 2012 23:54:12

Message: 3 of 7

"maan " <maan_waysi@yahoo.com> wrote in message <jj0umi$pi4$1@newscl01ah.mathworks.com>...
> A=0 1 1 1 0 1 1 0 ;
> A is of type logical
> i need to convert it to a string , so A will equal 'v'
- - - - - - - -
  What do you want the string content to be? FTTTFTTF, 01110110, or what? It would be whatever the 'v' array contains that you referred to.

Roger Stafford

Subject: convert logical to string

From: maan

Date: 5 Mar, 2012 00:06:12

Message: 4 of 7

"Roger Stafford" wrote in message <jj0vb4$r99$1@newscl01ah.mathworks.com>...
> "maan " <maan_waysi@yahoo.com> wrote in message <jj0umi$pi4$1@newscl01ah.mathworks.com>...
> > A=0 1 1 1 0 1 1 0 ;
> > A is of type logical
> > i need to convert it to a string , so A will equal 'v'
> - - - - - - - -
> What do you want the string content to be? FTTTFTTF, 01110110, or what? It would be whatever the 'v' array contains that you referred to.
>
> Roger Stafford

i have an xor result=01110110 , so i need to convert that result to Character ,,

so how to convert a logical vector to string of character ?? thank you

Subject: convert logical to string

From: maan

Date: 5 Mar, 2012 00:10:17

Message: 5 of 7

"Roger Stafford" wrote in message <jj0vb4$r99$1@newscl01ah.mathworks.com>...
> "maan " <maan_waysi@yahoo.com> wrote in message <jj0umi$pi4$1@newscl01ah.mathworks.com>...
> > A=0 1 1 1 0 1 1 0 ;
> > A is of type logical
> > i need to convert it to a string , so A will equal 'v'
> - - - - - - - -
> What do you want the string content to be? FTTTFTTF, 01110110, or what? It would be whatever the 'v' array contains that you referred to.
>
> Roger Stafford

another explain and i hope you will understand what i want

i need to convert logical vector to string .. so i can take each 8 bits of the logical
 vectors and convert it to it's equevilant of char ..

    
    A=0 1 1 1 0 1 1 0 1 1 0 0 0 0 1 ;
    A is of type logical
    i need to convert A to a string , so the string will equal = va

Subject: convert logical to string

From: Eduardo Montoya

Date: 5 Mar, 2012 01:10:13

Message: 6 of 7

"maan " <maan_waysi@yahoo.com> wrote in message <jj1099$p2$1@newscl01ah.mathworks.com>...
> "Roger Stafford" wrote in message <jj0vb4$r99$1@newscl01ah.mathworks.com>...
> > "maan " <maan_waysi@yahoo.com> wrote in message <jj0umi$pi4$1@newscl01ah.mathworks.com>...
> > > A=0 1 1 1 0 1 1 0 ;
> > > A is of type logical
> > > i need to convert it to a string , so A will equal 'v'
> > - - - - - - - -
> > What do you want the string content to be? FTTTFTTF, 01110110, or what? It would be whatever the 'v' array contains that you referred to.
> >
> > Roger Stafford
>
> another explain and i hope you will understand what i want
>
> i need to convert logical vector to string .. so i can take each 8 bits of the logical
> vectors and convert it to it's equevilant of char ..
>
>
> A=0 1 1 1 0 1 1 0 1 1 0 0 0 0 1 ;
> A is of type logical
> i need to convert A to a string , so the string will equal = va

Must be a better way, but..

From string:

v = '01110110'
a = '01100001'
A = [v a]

tostring = @(x)char(bin2dec(reshape(x,8,prod(size(x))/8)'))'
tostring(A)

v = cast([0 1 1 1 0 1 1 0],'logical')
a = cast([0 1 1 0 0 0 0 1],'logical')
A = [v a]

tostring = @(x)char(sum(bsxfun(@times,(2.^[7:-1:0]),reshape(x,8,prod(size(x))/8)'),2))'
tostring(A)

Subject: convert logical to string

From: maan

Date: 5 Mar, 2012 02:03:12

Message: 7 of 7

"Eduardo Montoya" wrote in message <jj13pl$a64$1@newscl01ah.mathworks.com>...
> "maan " <maan_waysi@yahoo.com> wrote in message <jj1099$p2$1@newscl01ah.mathworks.com>...
> > "Roger Stafford" wrote in message <jj0vb4$r99$1@newscl01ah.mathworks.com>...
> > > "maan " <maan_waysi@yahoo.com> wrote in message <jj0umi$pi4$1@newscl01ah.mathworks.com>...
> > > > A=0 1 1 1 0 1 1 0 ;
> > > > A is of type logical
> > > > i need to convert it to a string , so A will equal 'v'
> > > - - - - - - - -
> > > What do you want the string content to be? FTTTFTTF, 01110110, or what? It would be whatever the 'v' array contains that you referred to.
> > >
> > > Roger Stafford
> >
> > another explain and i hope you will understand what i want
> >
> > i need to convert logical vector to string .. so i can take each 8 bits of the logical
> > vectors and convert it to it's equevilant of char ..
> >
> >
> > A=0 1 1 1 0 1 1 0 1 1 0 0 0 0 1 ;
> > A is of type logical
> > i need to convert A to a string , so the string will equal = va
>
> Must be a better way, but..
>
> From string:
>
> v = '01110110'
> a = '01100001'
> A = [v a]
>
> tostring = @(x)char(bin2dec(reshape(x,8,prod(size(x))/8)'))'
> tostring(A)
>
> v = cast([0 1 1 1 0 1 1 0],'logical')
> a = cast([0 1 1 0 0 0 0 1],'logical')
> A = [v a]
>
> tostring = @(x)char(sum(bsxfun(@times,(2.^[7:-1:0]),reshape(x,8,prod(size(x))/8)'),2))'
> tostring(A)

Thank you very very very much ,, iam very glad now ,, thank you you were very helpful for me

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