Prev: Saving data after running parallel simulations
Next: ??? Attempt to reference field of non-structure array.
From: xiong on 23 Jan 2010 12:18 ImageAnalyst <imageanalyst(a)mailinator.com> wrote in message <a49abd4b-7577-4451-abaf-4d7353a99089(a)c34g2000yqn.googlegroups.com>... > On Jan 22, 6:35 am, "xiong " <xionglei092...(a)sina.com> wrote: > > ImageAnalyst <imageanal...(a)mailinator.com> wrote in message <56705f16-d25a-4c26-a742-324c67178...(a)a32g2000yqm.googlegroups.com>... > > > Well, the "if" function comes to mind > > > if distanceApart < minAllowableDistanceApart > > > % Code to throw away one of the two centroid locations > > > end > > > > Thank you for your kindness and patience. > > But I can not program it . > > Would you like to write some matlab code ? > > Sorry if I take your time. > > -------------------------------------------------------------------------------------------------------------------- > Yes you can. I have confidence in you. Once you read the "Getting > started" documentation, watch a few of the MATLAB video tutorials, and > do some of the other self-learning opportunities they provide, you'll > be programming miracles just like the hundreds of thousands of the > rest of us. It just seems hard at first. Just dedicate some time to > learning the basics and you'll be on your way. Even if I wrote that > little script for you, you can't really do much with it. You'd then > be wanting more and more MATLAB code, since I'm sure this is not the > final extent of what you'll need in MATLAB. Please recall the old > Chinese man/fish proverb. According to your teachiing: "if distanceApart < minAllowableDistanceApart > > % Code to throw away one of the two centroid locations > > end " I have programmed it : for i=1:200 a=data(i,:); Index=find(a); b=diff(Index); c=find(b<5); d=length(c); if d==0 data(i,:)=a; else while d >= 1 for i=1:length(c) if a(Index(c(i)))<=a(Index(c(i)+1)) a(Index(c(i)))=0; else a(Index(c(i)+1))=0; end end Index=find(a); b=diff(Index); c=find(b<5); end data(i,:)=a; end end Where data is a 200-by-500 matrix,but it does not work.Would you like to give me some advice about the codes I wrote? Look forward to your letter.
From: Oleg Komarov on 23 Jan 2010 13:40 "xiong " <xionglei092292(a)sina.com> > I have programmed it : > for i=1:200 > a=data(i,:); > Index=find(a); > b=diff(Index); > c=find(b<5); > d=length(c); > if d==0 > data(i,:)=a; > else > while d >= 1 > for i=1:length(c) > if a(Index(c(i)))<=a(Index(c(i)+1)) > a(Index(c(i)))=0; > else > a(Index(c(i)+1))=0; > end > end > Index=find(a); > b=diff(Index); > c=find(b<5); > end > data(i,:)=a; > end > end > > Where data is a 200-by-500 matrix,but it does not work.Would you like to give me some advice about the codes I wrote? > Look forward to your letter. I haven't folowed the discussion but you're suing the same looping index twice... And don't use 'i' as the looping index at all cause its already used by matlab. Oleg
First
|
Prev
|
Pages: 1 2 3 4 Prev: Saving data after running parallel simulations Next: ??? Attempt to reference field of non-structure array. |