Prev: XML Parsing
Next: using data generated in one callback in GUI in another callbackin the same GUI
From: james bejon on 30 Mar 2010 16:57 Dear All, Is there a neat way of getting from, say, [3, 5, 8] to [0, 0, 1, 0, 1, 0, 0, 1]?
From: Walter Roberson on 30 Mar 2010 17:07 james bejon wrote: > Dear All, Is there a neat way of getting from, say, > > [3, 5, 8] > > to > > [0, 0, 1, 0, 1, 0, 0, 1]? B = false(1,max(A)); B(A) = true;
From: David Young on 30 Mar 2010 17:09 x = [3 5 8]; y = zeros(1, max(x)); y(x) = 1
From: David Young on 30 Mar 2010 17:12 Oops I didn't look at the subject line, just the example. Walter's answer is the right one, ignore mine.
From: Walter Roberson on 30 Mar 2010 17:20 Walter Roberson wrote: > james bejon wrote: >> Dear All, Is there a neat way of getting from, say, >> >> [3, 5, 8] >> >> to >> >> [0, 0, 1, 0, 1, 0, 0, 1]? > > B = false(1,max(A)); > B(A) = true; Additional note: if there can be big gaps between the true values, then you may wish to consider using sparse arrays. Sparse arrays are supported for values of class double, and values of class logical, but (not as yet) for any other class.
|
Next
|
Last
Pages: 1 2 3 4 5 6 Prev: XML Parsing Next: using data generated in one callback in GUI in another callbackin the same GUI |