Borrar filtros
Borrar filtros

Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

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 visualización (últimos 30 días)
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 comentarios
Mathieu NOE
Mathieu NOE el 30 de Nov. de 2023
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

Respuestas (0)

La pregunta está cerrada.

Etiquetas

Productos


Versión

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by