From: Chris on
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?
From: Frank on
A(A<min(A)) = min(A);
A(A>max(A)) = max(A);

From: Matt Fig on
Frank <fbleahy(a)yahoo.com> wrote in message <0842fcba-9682-4315-a9fd-8839d063af2f(a)z26g2000yqm.googlegroups.com>...
> A(A<min(A)) = min(A);
> A(A>max(A)) = max(A);



The left hand side of those expressions is always empty!


To the OP:
Do you mean this?

% Data
mymin = 3; % We want nothing less than this
mymax = 7; % And nothing larger than this.
A = randperm(10)

% Engine
A = max(A,mymin);
A = min(A,mymax)
From: Chris on
Thank you. That was very helpful.
From: Chris on
> % Data
> mymin = 3; % We want nothing less than this
> mymax = 7; % And nothing larger than this.
> A = randperm(10)
>
> % Engine
> A = max(A,mymin);
> A = min(A,mymax)

_____________________________________________________

this one is nicer. I got the other one to work with some manipulation but I think I will try this one too. Thanks.