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

2 ビュー (過去 30 日間)
M
M 2022 年 9 月 11 日
コメント済み: Star Strider 2022 年 9 月 11 日
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
Star Strider 2022 年 9 月 11 日
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')
.
  4 件のコメント
M
M 2022 年 9 月 11 日
@Star Strider Can you please check the centroid question of the same shape!
I have mentioned you in the question. Thanks
Star Strider
Star Strider 2022 年 9 月 11 日
I did, and I just posted an Answer.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeInterpolation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by