Getting x for a given y value from a cfit object

I have a cfit object:
[expfit, gof] = fit(-pos,sam_data,'exp1','Exclude',excluded);
From this I can extract the fit parameters (which in the case of 'exp1' are) expfit.a, expfit.b. From here, I could define the inverse equation to and solve for x by evaluating at y.
I want to find out what the x-value is at:
y = exp(-1)*max(sam_data)
without finding the inverse equation. How can I do this?

回答 (2 件)

Star Strider
Star Strider 2020 年 12 月 7 日

0 投票

2 件のコメント

jdl3141
jdl3141 2020 年 12 月 7 日
I want to find out what the x-value is at:
y = exp(-1)*max(sam_data)
without finding the inverse equation. How can I do this?
Star Strider
Star Strider 2020 年 12 月 7 日
Try this:
pos = linspace(-5,5); % Create Data
a = 3; % Guess The Parameter Value
b = 5; % Guess The Parameter Value
sam_data = a*exp(b*pos); % Create Data
y = exp(-1)*max(sam_data);
xq = interp1(sam_data, pos, exp(-1)*max(sam_data)); % Desired Result
.

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

Steven Lord
Steven Lord 2020 年 12 月 7 日

0 投票

x = 2*rand(20, 1);
y = 1.25*sin(x+0.3+rand(size(x)));
f = fit(x, y, 'sin1')
f =
General model Sin1: f(x) = a1*sin(b1*x+c1) Coefficients (with 95% confidence bounds): a1 = 1.222 (1.043, 1.401) b1 = 1.149 (0.8509, 1.446) c1 = 0.5366 (0.1605, 0.9127)
desiredy = 0.75;
fun = @(x) desiredy - f(x);
desiredx = fzero(fun, 0)
desiredx = 0.1081
f(desiredx) % should be closer to desiredy
ans = 0.7500

カテゴリ

ヘルプ センター および File ExchangeMathematics and Optimization についてさらに検索

製品

リリース

R2019a

質問済み:

2020 年 12 月 7 日

回答済み:

2020 年 12 月 7 日

Community Treasure Hunt

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

Start Hunting!

Translated by