hi friends,
i have an ascii word and its binary state:
x = dec2bin('matlab')
x =
1101101
1100001
1110100
1101100
1100001
1100010
but i do not want this in this way... i want it like an array that is below:
y = 110110111000011110100110110011000011100010
the question is how can i convert x to y?
i tried reshape() function but i couldnt success :(
please let me know...

 採用された回答

Sean de Wolski
Sean de Wolski 2011 年 5 月 19 日

0 投票

y = reshape(x',1,numel(x))
transpose first

7 件のコメント

osman yurdakul
osman yurdakul 2011 年 5 月 19 日
so can i use y like an array whose dimension 1x42?
the thing that i want to say;
i can an array by randint() function
for ex;
a = randint(1,42);
a is an array and its dimension is 1x42;
now i want y to be like a that is above...
Walter Roberson
Walter Roberson 2011 年 5 月 19 日
Yup. But I do recommend explicitly putting the number of bits you want in to the dec2bin() call, such as dec2bin('matlab',8)
Matt Fig
Matt Fig 2011 年 5 月 19 日
If you mean that you want the strings to be numbers in an array,
yv = arrayfun(@str2double,y)
osman yurdakul
osman yurdakul 2011 年 5 月 19 日
thank you all so much for your support :) it's working now..
osman yurdakul
osman yurdakul 2011 年 5 月 20 日
sorry again me :)
so if i want to turn back to y from yv how can i carry out this?
Matt Fig
Matt Fig 2011 年 5 月 20 日
sprintf('%i',yv)
osman yurdakul
osman yurdakul 2011 年 5 月 20 日
thanks again :)..

サインインしてコメントする。

その他の回答 (1 件)

Fangjun Jiang
Fangjun Jiang 2011 年 5 月 19 日

0 投票

y=x';
xx=y(:)'

カテゴリ

ヘルプ センター および File Exchange で Creating and Concatenating Matrices についてさらに検索

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by