how to find value of x for a known value of y(x), using fplot?

12 ビュー (過去 30 日間)
Nora Khaled
Nora Khaled 2020 年 3 月 12 日
コメント済み: Walter Roberson 2020 年 3 月 15 日
Hi !
I am using the function fplot to plot 5 functions. and the plot is working good.
now for each function I am trying to get the value of the x axis that makes the function equal to a certain value.
my current code is:
syms z(x)
z(x)=h(x)-f(x);
zValues=[0.6250 2.5000 10.0000 15.6250 22.5000];
%plot z(x)
figure;
fplot(z,'-','LineWidth',2)
axis([-35 35 -35 35]);
grid on;
yline(0);
xline(0);
and I get this plot:
I want to use the variable zValues to get 5 x values. such that for the blue line z(x) = 0.625 then x= ...
is there a way to do that?
Edit/ Note:
if the function z(x) was only one plot ( say the blue one ) I can use this:
solve(z(x)==zValues,x)
in this case zValues would be be one constant not a vector.
  1 件のコメント
darova
darova 2020 年 3 月 12 日
Do you have polyxpoly? Or intersections

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

採用された回答

Nora Khaled
Nora Khaled 2020 年 3 月 12 日
The only way I was able to do this is to change z(x).
insted of having all the lines in one plot. I created a loop such that at each eteration z(x) is one line.
then I used
solve(z(x)==zValues,x)
it takes time but I got the results.
  3 件のコメント
Nora Khaled
Nora Khaled 2020 年 3 月 15 日
Thank you!
one thing though, I don't understand what the array function does?
Walter Roberson
Walter Roberson 2020 年 3 月 15 日
https://www.mathworks.com/help/matlab/ref/arrayfun.html

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by