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:
conversion of number matrix into string

Subject: conversion of number matrix into string

From: anil chandy

Date: 9 Jan, 2009 05:24:02

Message: 1 of 4

hi friends..
can anyone pls help me out in converting a number matrix into string so that i can use bin2dec command on it.
1 1 1 1 0 0 0 0
1 1 0 0 1 1 1 1 etc into

11110000
11001111


thanks.

Subject: conversion of number matrix into string

From: Bruno Luong

Date: 9 Jan, 2009 06:08:02

Message: 2 of 4

"anil chandy" <anilvchandy@gmail.com> wrote in message <gk6n1h$juh$1@fred.mathworks.com>...
> hi friends..
> can anyone pls help me out in converting a number matrix into string so that i can use bin2dec command on it.
> 1 1 1 1 0 0 0 0
> 1 1 0 0 1 1 1 1 etc into
>
> 11110000
> 11001111
>

b=[1 1 1 1 0 0 0 0;
     1 1 0 0 1 1 1 1]

char(b+'0')

Bruno

Subject: conversion of number matrix into string

From: Srikanth

Date: 9 Jan, 2009 06:16:55

Message: 3 of 4

See mat2str - you might need to reshape the resulting string and
remove some elements before using bin2dec.

Subject: conversion of number matrix into string

From: Steven Lord

Date: 9 Jan, 2009 14:40:17

Message: 4 of 4


"anil chandy" <anilvchandy@gmail.com> wrote in message
news:gk6n1h$juh$1@fred.mathworks.com...
> hi friends..
> can anyone pls help me out in converting a number matrix into string so
> that i can use bin2dec command on it.
> 1 1 1 1 0 0 0 0
> 1 1 0 0 1 1 1 1 etc into
>
> 11110000
> 11001111

If your goal is to treat each row of the numeric matrix as the binary
representation of a number, and to convert those binary representations into
the numbers, you don't need to convert to a string first. Use matrix-vector
multiplication.

A = round(rand(10, 8))
values = A*2.^((size(A, 2)-1:-1:0).')

--
Steve Lord
slord@mathworks.com

Tags for this Thread

No tags are associated with 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