From: kk KKsingh on
Generate a random sample..from N samples and it should be even always, what should i add it i dont wana use loop thinng

kn1=randperm(N);
% Randomly eliminating some samples
percent=.70 %70 percent
kn2=kn1(1:ceil(percent*N));
% sorting random chosen traces in ascending order
z=[sort(kn2)];

z should always be even number of samples, how to get it ..i some time get them odd
From: nanren888 on
"kk KKsingh" <akikumar1983(a)gmail.com> wrote in message <hmrs1o$jhb$1(a)fred.mathworks.com>...
> Generate a random sample..from N samples and it should be even always, what should i add it i dont wana use loop thinng
>
> kn1=randperm(N);
> % Randomly eliminating some samples
> percent=.70 %70 percent
> kn2=kn1(1:ceil(percent*N));
> % sorting random chosen traces in ascending order
> z=[sort(kn2)];
>
> z should always be even number of samples, how to get it ..i some time get them odd

Sorry, can you explain the problem a little more clearly?
You take the first N*percent samples out of N.
Why would that always be even?
From: kk KKsingh on
In the my algorithm i always need some odd number other wise my algorithm gives me error later....if z is even like suppose if z is 7 i want it to become 8 or 6.....it will ease my algorithm......And with below mention algorithm it gives me odd most of time

kn1=randperm(N);
% Randomly eliminating some samples
percent=.70 %70 percent
kn2=kn1(1:ceil(percent*N));
% sorting random chosen sampless in ascending order
z=[sort(kn2)];


"nanren888 " <nanren888.remove.this(a)hotmail.com> wrote in message <hmru5a$1do$1(a)fred.mathworks.com>...
> "kk KKsingh" <akikumar1983(a)gmail.com> wrote in message <hmrs1o$jhb$1(a)fred.mathworks.com>...
> > Generate a random sample..from N samples and it should be even always, what should i add it i dont wana use loop thinng
> >
> > kn1=randperm(N);
> > % Randomly eliminating some samples
> > percent=.70 %70 percent
> > kn2=kn1(1:ceil(percent*N));
> > % sorting random chosen traces in ascending order
> > z=[sort(kn2)];
> >
> > z should always be even number of samples, how to get it ..i some time get them odd
>
> Sorry, can you explain the problem a little more clearly?
> You take the first N*percent samples out of N.
> Why would that always be even?
From: Nathan on
On Mar 5, 2:39 pm, "kk KKsingh" <akikumar1...(a)gmail.com> wrote:
> In the my algorithm i always need some odd number other wise my algorithm gives me error later....if z is even like suppose if z is 7 i want it to become 8 or 6.....it will ease my algorithm......And with below mention algorithm it gives me odd most of time
>
> kn1=randperm(N);
> % Randomly eliminating some samples
> percent=.70 %70 percent
> kn2=kn1(1:ceil(percent*N));
> % sorting random chosen sampless in ascending order
> z=[sort(kn2)];
>
> "nanren888 " <nanren888.remove.t...(a)hotmail.com> wrote in message <hmru5a$1d...(a)fred.mathworks.com>...
> > "kk KKsingh" <akikumar1...(a)gmail.com> wrote in message <hmrs1o$jh...(a)fred.mathworks.com>...
> > > Generate a random sample..from N samples and it should be even always, what should i add it i dont wana use loop thinng
>
> > > kn1=randperm(N);
> > > % Randomly eliminating some samples
> > > percent=.70 %70 percent
> > > kn2=kn1(1:ceil(percent*N));
> > > % sorting random chosen traces in ascending order
> > > z=[sort(kn2)];
>
> > > z should always be even number of samples, how to get it ..i some time get them odd
>
> > Sorry, can you explain the problem a little more clearly?
> > You take the first N*percent samples out of N.
> > Why would that always be even?
>
>

One way to force z to be of even length:

kn1=randperm(N);
% Randomly eliminating some samples
percent=.70; %70 percent
%%%%
kn2=kn1(1:(2*ceil(percent*N./2)));
%%%%
% sorting random chosen sampless in ascending order
z=[sort(kn2)];
From: Walter Roberson on
kk KKsingh wrote:
> Generate a random sample..from N samples and it should be even always,
> what should i add it i dont wana use loop thinng
>
> kn1=randperm(N);
> % Randomly eliminating some samples
> percent=.70 %70 percent
> kn2=kn1(1:ceil(percent*N));
> % sorting random chosen traces in ascending order
> z=[sort(kn2)];
>
> z should always be even number of samples, how to get it ..i some time
> get them odd

kn2 = kn1(1:ceil(percent*N/2)*2);