Prev: XML Parsing
Next: using data generated in one callback in GUI in another callbackin the same GUI
From: dpb on 30 Mar 2010 17:37 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]? Alternately, o(x)=1; % create the 0/1 vector l = logical(o); % turn it into a logical one Too bad for things like this ML doesn't support nested assignment.. l = logical(o(x)=1); % Doesn't work, of course... :( --
From: Nathan on 30 Mar 2010 17:43 On Mar 30, 2:37 pm, dpb <n...(a)non.net> 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]? > > Alternately, > > o(x)=1; % create the 0/1 vector > l = logical(o); % turn it into a logical one > > Too bad for things like this ML doesn't support nested assignment.. > > l = logical(o(x)=1); % Doesn't work, of course... :( > > -- If you were going to do that, why not just make it logical in the first place? o(x) = true; -Nathan
From: dpb on 30 Mar 2010 17:51 Nathan wrote: .... > If you were going to do that, why not just make it logical in the > first place? > > o(x) = true; Primarily because... >> which true true not found. >> help true true.m not found. >> :( --
From: Walter Roberson on 30 Mar 2010 17:54 dpb 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]? > > Alternately, > > o(x)=1; % create the 0/1 vector > l = logical(o); % turn it into a logical one > > Too bad for things like this ML doesn't support nested assignment.. > > l = logical(o(x)=1); % Doesn't work, of course... :( Well, if you are going to be like that! l = any(bsxfun(@eq,1:max(x),x.'));
From: james bejon on 30 Mar 2010 18:08
Thanks for all the really helpful replies! I'm currently toying with the (perhaps hungry?) expression: ismember((1:A(end)), A) (I can assume A is in ascending order) |