From: someone on
john <mushtaq.jaffar(a)yahoo.com> wrote in message <1592537430.38822.1279833090745.JavaMail.root(a)gallium.mathforum.org>...
> kindly find here the code i want to implement:
>
> %%% CODE
>
> search_Range=[-2.45 +2.45] % here i want to mention values between -2.45 and +2.45 but no values less than +0.65 or -0.65

That doesn't make much sense.
Do you mean no values BETWEEN +0.65 and -0.65?

>
> pop_Size= 10;
>
> indiv_Size = 30;
>
> population(1:pop_Size,1:indiv_Size)=search_Range(1)+(search_Range(2)-search_Range(1))*rand(pop_Size,indiv_Size);
From: Roger Stafford on
john <mushtaq.jaffar(a)yahoo.com> wrote in message <1592537430.38822.1279833090745.JavaMail.root(a)gallium.mathforum.org>...
> kindly find here the code i want to implement:
>
> %%% CODE
>
> search_Range=[-2.45 +2.45] % here i want to mention values between -2.45 and +2.45 but no values less than +0.65 or -0.65
>
> pop_Size= 10;
>
> indiv_Size = 30;
>
> population(1:pop_Size,1:indiv_Size)=search_Range(1)+(search_Range(2)-search_Range(1))*rand(pop_Size,indiv_Size);
- - - - - - - - - - -
John, you have twice said "but no values less than +0.65 or -0.65", but that seems a careless way to state things since it is surely not what you really mean nor is it even good English. This has created needless confusion in this thread as to what you do mean. Perhaps you mean "but no values between +0.65 and -0.65" which is the "hole in the center" interpretation others are referring to. You should think carefully before putting out sloppy statements like the above in a newsgroup where it can be read by hundreds of others. It makes it less likely that you will get useful help.

Assuming the hole-in-the-center interpretation is correct, you could do it this way:

a = 2.45;
b = 0.65;
t = rand(m,n); % For m x n of them
r = 2*(a-b)*t-a+2*b*(t>=.5); % r lies either in [-a,-b] or in [b,a]

(This is similar to Walter's but calls on rand only once per data point.)

Roger Stafford