フィルターのクリア

Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Hi, i'm just wonder can Matlab have any function to find asymptotes of y = f(x) that satisfy x = x(t) and y = y(t). I have try many solutions but nothing is success.

1 回表示 (過去 30 日間)
Nhat Huy
Nhat Huy 2023 年 11 月 30 日
閉鎖済み: John D'Errico 2023 年 12 月 1 日
syms t;
x_t = (t+1)./(t-1);
y_t = (t^2 + 2)./(t^2 - t);
figure;
hold on;
grid on;
fplot(x_t, y_t);
  4 件のコメント
Mathieu NOE
Mathieu NOE 2023 年 11 月 30 日
I don't have the symbolic toolbox , so the best I could get i this numerical approach
t = (-1:1e-3:3);
x_t = (t+1)./(t-1);
y_t = (t.^2 + 2)./(t.^2 - t);
figure(1);
plot(x_t, y_t);
ylim([-30 30]);
hold on
% remove Inf values
id = (x_t==Inf | y_t==Inf);
x_t(id) = [];
y_t(id) = [];
% horizontal asymptote
[v1,i1] = min(x_t);
[v2,i2] = max(x_t);
x1 = [v1;v2];
y1 = [y_t(i1);y_t(i2)];
plot(x1, y1,'r--');
% y = ax+b
a = diff(y1)/diff(x1);
b = mean(y1 - a*x1);
eqnH = poly_equation([b a]); % polynomial equation (string)
% vertical asymptote
y_temp = y_t - (a*x_t+b);
[v1,i1] = min(y_temp);
[v2,i2] = max(y_temp);
y2 = [v1;v2];
x2 = [x_t(i1);x_t(i2)];
plot(x2, y2,'g--');
% y = ax+b
a = diff(y2)/diff(x2);
b = mean(y2 - a*x2);
eqnV = poly_equation([b a]); % polynomial equation (string)
legend('data',eqnH,eqnV)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function eqn = poly_equation(a_hat)
eqn = " y = "+a_hat(1);
for i = 2:(length(a_hat))
if sign(a_hat(i))>0
str = " + ";
else
str = " ";
end
if i == 2
eqn = eqn+str+a_hat(i)+"*x";
else
eqn = eqn+str+a_hat(i)+"*x^"+(i-1)+" ";
end
end
eqn = eqn+" ";
end
Nhat Huy
Nhat Huy 2023 年 12 月 1 日
it works pretty well. Thank you.

回答 (0 件)

この質問は閉じられています。

タグ

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by