"anoop Sivasankaran" <anooppgd@gmail.com> wrote in message <h75gg6$odo$1@fred.mathworks.com>...
> I am making a very fundamental mistake here, which I am not able to identify. I have a data file dat(320000X4)
>
> r1 = dat(:,1);
> r2 = dat(:,2);
> a=0.86;
> b=0.85;
> c=0.87;
> d=0.89;
> k= find(dat(:,3) ~= 0);
> if (r2(k) < b & r1(k) > a)
> plot(dat(k,1),dat(k,2),'g.');
> end
>
> Why this is giving me an empty plot all the time?
Hi Anoop, The way you have written the code, how is that if statement supposed to evaluate? r2(k) is a vector, r1(k) is a vector (presumably if there is more than one index in dat(:,3) that is not equal to zero). So you are asking if a vector is less than b (a scalar), and a vector is greater than a (another scalar). Try the way I've written it below with some junk data input and see if it makes sense why that if statement cannot work.
dat = randn(1024,3); %creating some junk data
Y = randsample(1024,50); % just to make some zeros randsample() in stats toolbox
dat(Y,3) = 0;
r1 = dat(:,1);
r2 = dat(:,2);
a = 0.86;
b = 0.85;
k = find(dat(:,3) ~= 0);
sig_values = find(r2(k) < b & r1(k) > a);
plot(r1(sig_values),r2(sig_values),'g.');
Hope that helps,
wayne
