# How to find projection on a set

7 views (last 30 days)
Yokuna on 18 Feb 2022
Answered: Matt J on 18 Feb 2022
Let us define . We have
g1=(x1-100)*(x1-150)<=0;
g2=(x2-100)*(x2-150)<=0;
g3=(x3-100)*(x3-200)<=0; I want to find . Please help me find the projection fun P as defined. I tried this code but it gives error.
syms x1 x2 x3 g1 g2 g3 t
g1=(x1-100)*(x1-200)<=0;
g2=(x2-100)*(x2-200)<=0;
g3=(x3-100)*(x3-200)<=0;
% g1,g2,g3 has set of values of x1, x2, x3.
[difference, index_At_F_Equals_x1] = argmin(abs(g1-x1))
% Value of projection fun
P1 = g1(index_At_F_Equals_x1)
[difference, index_At_F_Equals_x2] = argmin(abs(g2-x2))
P2 = g2(index_At_F_Equals_x2)
[difference, index_At_F_Equals_x3] = argmin(abs(g3-x3))
P3 = g3(index_At_F_Equals_x3)

Matt J on 18 Feb 2022
The set appears just to be a box, so,
lb=[100;100;100];
ub=[150;150;200];
P= @(x) min( max(x(:),lb) ub);

### Categories

Find more on Symbolic Math Toolbox in Help Center and File Exchange

R2017b

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!