From: Kris zenitis on 27 Apr 2010 20:06 Nathan <ngreco32(a)gmail.com> wrote in message <754a0f2f-ab9d-4a00-8c92-db5214d02d9c(a)s36g2000prf.googlegroups.com>... > On Apr 27, 4:31 pm, "Kris zenitis" <gio.1...(a)hotmai.com> wrote: > > Exactly Nathan i want 1<=x<=261, 1<=y<=441. > > Do you want the zeros turned to ones or left out completely? > > -Nathan I want to left them out utterly.
From: Nathan on 27 Apr 2010 20:15 On Apr 27, 5:06 pm, "Kris zenitis" <gio.1...(a)hotmai.com> wrote: > Nathan <ngrec...(a)gmail.com> wrote in message <754a0f2f-ab9d-4a00-8c92-db5214d02...(a)s36g2000prf.googlegroups.com>... > > On Apr 27, 4:31 pm, "Kris zenitis" <gio.1...(a)hotmai.com> wrote: > > > Exactly Nathan i want 1<=x<=261, 1<=y<=441. > > > Do you want the zeros turned to ones or left out completely? > > > -Nathan > > I want to left them out utterly. Alright: k = 1; %counter for xx m = 1; %counter for yy for ii=1:n if dec_values(ii)>0 x=mod(ii,262); y=mod(ii,442); if x>0 xx(k,1) = x; k = k + 1; end if y>0 yy(m,1) = x; m = m + 1; end end end Or something like that. Note that x and y will not necessarily be the same size when doing it this way. If you want x and y to be paired up such that if x OR y == 0, then both of them are discarded, then you can use one counting variable in an if-statement as such: if x > 0 && y > 0 xx(k,1) = x; yy(k,1) = y; k = k+1; end -Nathan
From: Kris zenitis on 27 Apr 2010 20:39 > Or something like that. Note that x and y will not necessarily be the > same size when doing it this way. > If you want x and y to be paired up such that if x OR y == 0, then > both of them are discarded, then you can use one counting variable in > an if-statement as such: > > if x > 0 && y > 0 > xx(k,1) = x; > yy(k,1) = y; > k = k+1; > end > > > -Nathan This is what from the beggining i tried but i dont understand for some reason && it doesnt works properly i have this for exmple for i=1:n if xx(i,1)>0 && yy(i,1) what=yy(i,1)/xx(i,1); end end buth i have this message that i ve tried to divide with zero. General thanks i have to go for sleeping. I ll continue tomorrow for this stuff.
From: Nathan on 27 Apr 2010 20:50 On Apr 27, 5:39 pm, "Kris zenitis" <gio.1...(a)hotmai.com> wrote: > > Or something like that. Note that x and y will not necessarily be the > > same size when doing it this way. > > If you want x and y to be paired up such that if x OR y == 0, then > > both of them are discarded, then you can use one counting variable in > > an if-statement as such: > > > if x > 0 && y > 0 > > xx(k,1) = x; > > yy(k,1) = y; > > k = k+1; > > end > > > -Nathan > > This is what from the beggining i tried but i dont understand for some reason && it doesnt works properly > > i have this for exmple for i=1:n > if xx(i,1)>0 && yy(i,1) > what=yy(i,1)/xx(i,1); > end > end > > buth i have this message that i ve tried to divide with zero. > General thanks i have to go for sleeping. I ll continue tomorrow for this stuff. You are not telling us something if this isn't working for you. .... PLEASE try to understand what we are telling you and use it correctly. k = 1; %counter for ii=1:n if dec_values(ii)>0 x=mod(ii,262); y=mod(ii,442); if x > 0 && y > 0 xx(k,1) = x; yy(k,1) = y; k = k+1; end end end If THIS does not do what you want, then you are asking us the wrong questions. PLEASE rethink about what you are trying to do and state CLEARLY what you want done. Note: a modified vectorized result is as follows: idx = find(dec_values>0); x = mod(idx,262); y = mod(idx,442); idx2 = ~(x&y); %finds where x == 0 OR y == 0 x(idx2) = []; %delete 0 elements y(idx2) = []; %delete 0 elements -Nathan
From: Matt Fig on 27 Apr 2010 21:03
Nathan <ngreco32(a)gmail.com> wrote in message <38a0cd0c-4c29-46a1-9da5- > Note that 0 is not positive, Matt. I wonder if the OP is just wanting > -Nathan Ach! Missed that one! Of course it seems there is a lot of guesswork going on in this thread. :-) |