From: James Tursa on
"Chris " <ridered300tr(a)hotmail.com> wrote in message <hjstjo$l0v$1(a)fred.mathworks.com>...
> I am trying to form a vector using the max and min's
> I want all values smaller than my min to become the min a vice versa with the max. I can single out the min's and max's and even combine them. But I need to take the original vector and make whatever isn't in the max/min range to be the max/min.
>
> Any suggestions?

A = rand(1,10)
A(A<.4) = .4
A(A>.6) = .6

James Tursa
From: Frank on
On Jan 28, 3:12 pm, Frank <fble...(a)yahoo.com> wrote:
> A(A<min(A)) = min(A);
> A(A>max(A)) = max(A);

Duh.....don't know what I was thinking. Sorry for being an idiot. I
was thinking something more along the lines of James' solution.
From: Jos (10584) on
"James Tursa" <aclassyguy_with_a_k_not_a_c(a)hotmail.com> wrote in message <hjt1ba$g4h$1(a)fred.mathworks.com>...
> "Chris " <ridered300tr(a)hotmail.com> wrote in message <hjstjo$l0v$1(a)fred.mathworks.com>...
> > I am trying to form a vector using the max and min's
> > I want all values smaller than my min to become the min a vice versa with the max. I can single out the min's and max's and even combine them. But I need to take the original vector and make whatever isn't in the max/min range to be the max/min.
> >
> > Any suggestions?
>
> A = rand(1,10)
> A(A<.4) = .4
> A(A>.6) = .6
>
> James Tursa

Or use the max-min one-liner:

A = ceil(10 * rand(1,10))
Limits = [3 7]
A = max(min(A, Limits(2)), Limits(1))

Jos