|
From: | David Bateman |
Subject: | Re: transform a string with variable length to a matrix |
Date: | Thu, 28 Aug 2008 12:54:27 +0200 |
User-agent: | Thunderbird 2.0.0.16 (X11/20080725) |
Goebel, Juergen wrote:
The de2bi function in the communications toolbox does what you want.. The advantage is that it handles matrices for speed. For exampleHi, Using dec2bin I transform a decimal number to a binary number with an a priori unknown number of digits. But the next step offers a little problem for me: I have to transform the resulting string to a matrix of ones and zeros. Trying a bit with str2mat like str2mat([a(1);a(2);a(3)] wasn't successful 'cause the number of digits is variable. I'm sure some wizard can tell me what I have to do ... Regards, Jürgen ------------------------------------------------------------------------ _______________________________________________ Help-octave mailing list address@hidden https://www-old.cae.wisc.edu/mailman/listinfo/help-octave
octave:1> de2bi(0:15) ans = 0 0 0 0 1 0 0 0 0 1 0 0 1 1 0 0 0 0 1 0 1 0 1 0 0 1 1 0 1 1 1 0 0 0 0 1 1 0 0 1 0 1 0 1 1 1 0 1 0 0 1 1 1 0 1 1 0 1 1 1 1 1 1 1 octave:2> de2bi([0:15],"left-msb") ans = 0 0 0 0 0 0 0 1 0 0 1 0 0 0 1 1 0 1 0 0 0 1 0 1 0 1 1 0 0 1 1 1 1 0 0 0 1 0 0 1 1 0 1 0 1 0 1 1 1 1 0 0 1 1 0 1 1 1 1 0 1 1 1 1 D. -- David Bateman address@hiddenMotorola Labs - Paris +33 1 69 35 48 04 (Ph) Parc Les Algorithmes, Commune de St Aubin +33 6 72 01 06 33 (Mob) 91193 Gif-Sur-Yvette FRANCE +33 1 69 35 77 01 (Fax) The information contained in this communication has been classified as: [x] General Business Information [ ] Motorola Internal Use Only [ ] Motorola Confidential Proprietary
[Prev in Thread] | Current Thread | [Next in Thread] |