How do I get the values of x at y=0.67 and y=0.87

6 ビュー (過去 30 日間)
Kalyan Dash
Kalyan Dash 2018 年 2 月 5 日
コメント済み: Rik 2018 年 2 月 6 日
x=linspace(0,4,100);
y=zeros(size(x));
p=0.275;
figure
k=2.031;
for i=1:numel(x)
y(i)=(exp(-(p*(x(i)))^k));
end
axis([0 4 0 1.8])
plot(x,y,'--')
xlabel('x')
ylabel('y')
How do I calculate the corresponding x value for any given y value.

回答 (2 件)

Rik
Rik 2018 年 2 月 5 日
You can reverse the formula with pen and paper (and maybe some Wolfram-Aplha), interpolate with a function like interp1, or solve the equation with solve. The first method doesn't really involve Matlab, and for the latter two the documentation should be self-explanatory. Nonetheless, if you have questions, you should of course feel free to post a comment here.

Torsten
Torsten 2018 年 2 月 5 日
x = (log(1/y))^(1/k)/p
Best wishes
Torsten.
  2 件のコメント
Kalyan Dash
Kalyan Dash 2018 年 2 月 6 日
Most of the time the expressions are much complex. So back calculation is not possible. So I want to get the answer from graph.
Have a look at the following code
Here it works fine. But in my code the variable y is an array and the plot is done Vs x and y arrays. So above code is not working.
Rik
Rik 2018 年 2 月 6 日
x = (log(1./y)).^(1/k)/p
Don't forget element-wise operations if you want to use arrays. And if the expression is too complex to reverse, use either of the other solutions I mentioned in my answer.

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

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by