On Mar 5, 2:39 pm, "kk KKsingh" <akikumar1...@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...@hotmail.com> wrote in message <hmru5a$1d...@fred.mathworks.com>...
> > "kk KKsingh" <akikumar1...@gmail.com> wrote in message <hmrs1o$jh...@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)];
