Path: news.mathworks.com!not-for-mail From: "Rob Joy" <joek91@yahoo.com> Newsgroups: comp.soft-sys.matlab Subject: Re: How to merge two vectors using special rule? Date: Thu, 1 Jan 2009 00:03:01 +0000 (UTC) Organization: FH Technikum Wien Lines: 43 Message-ID: <gjh17l$3nf$1@fred.mathworks.com> References: <gjgk1q$juh$1@fred.mathworks.com> <gjgo9c$3g9$1@fred.mathworks.com> <gjgr6i$rfd$1@fred.mathworks.com> Reply-To: "Rob Joy" <joek91@yahoo.com> NNTP-Posting-Host: webapp-02-blr.mathworks.com Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit X-Trace: fred.mathworks.com 1230768181 3823 172.30.248.37 (1 Jan 2009 00:03:01 GMT) X-Complaints-To: news@mathworks.com NNTP-Posting-Date: Thu, 1 Jan 2009 00:03:01 +0000 (UTC) X-Newsreader: MATLAB Central Newsreader 1382147 Xref: news.mathworks.com comp.soft-sys.matlab:509378 Hallo Roger, - There are only 1s in a - There are only -1s in b - If one block interrupts another but then quits before the first one is finished, interrupted block has no relevancy any more (from the point of interruption) and from this point only the first block that interrupts will be validated. a = [0 1 1 1 1 1 1 b = [0 0 0 -1 -1 0 0 r = [0 1 1 -1 -1 0 0 Thanks Joe "Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <gjgr6i$rfd$1@fred.mathworks.com>... > "Matt " <mjacobson.removethis@xorantech.com> wrote in message <gjgo9c$3g9$1@fred.mathworks.com>... > > "Rob Joy" <joek91@yahoo.com> wrote in message <gjgk1q$juh$1@fred.mathworks.com>... > > > Hallo, > > > > > > I have following Problem: > > > > > > I would like to merge this two vectors. Each new starting block of ones or minus ones in a or b overrides the other already running block of ones or minus ones. > > > > > > a = [0 0 1 1 1 1 0 0 0 1 1 1 1 0 1 1 1 1 ]'; > > > b = [0 0 0 0 -1 -1 -1 -1 0 0 0 -1 -1 -1 -1 0 0 0]'; > > > > > > The result schould be like this: > > > > > > result = [0 0 1 1 -1 -1 -1 -1 0 1 1 -1 -1 -1 1 1 1 1]'; > > > > > > Another question is, how to get idx of starting blocks of ones and minus ones in result. > > > Should generate [3 5 10 12 15] > > > > What happens if a block of -1s in "a" starts running at the same point as a block of 1s in "b"? Which overrides the other? > > Besides Matt's question there is also the matter of how to proceed if one block interrupts another but then quits before the first one is finished: > > a = [0 1 1 1 1 1 1 > b = [0 0 0 -1 -1 0 0 > r = [0 1 1 -1 -1 ? ? > > Also can 'a' have -1 blocks or 'b' have 1 blocks, and if so how are these to be handled? > > Roger Stafford