# How to know the x projection in this function if the y is known?

2 views (last 30 days)
M on 11 Sep 2022
Commented: Star Strider on 11 Sep 2022
How to know the x projection in this function if the y is known? For example If the y = 0.4 what is the x?
xA = 0;
xB = 1;
xf = 1
x = linspace(0, xf, xf*1e4 + 1);
a = 9.2; %
c = 0.5; % center of function
Y = sigmf(x, [a c]).*((0 <= (x - xA)) & ((x - xA) < (xB - xA)));

Star Strider on 11 Sep 2022
Use interp1 to interpolate —
xA = 0;
xB = 1;
xf = 1;
x = linspace(0, xf, xf*1e4 + 1);
a = 9.2; %
c = 0.5; % center of function
Y = sigmf(x, [a c]).*((0 <= (x - xA)) & ((x - xA) < (xB - xA)));
yq = 0.4;
xq = interp1(Y, x, yq)
xq = 0.4559
figure
plot(x, Y)
hold on
plot(xq, yq, 'sr')
hold off
grid
text(xq, yq, sprintf(' \\leftarrow, (%.2f, %.2f)', xq, yq), 'Horiz','left', 'Vert','middle')
.
M on 11 Sep 2022
@Star Strider Can you please check the centroid question of the same shape!
I have mentioned you in the question. Thanks
Star Strider on 11 Sep 2022
I did, and I just posted an Answer.