i'd like to ask is there any function to find asymptotes of an equation y = f(x) that satisfies x = x(t) and y = y(t). I'm new to matlab.
2 次查看(过去 30 天)
显示 更早的评论
syms t
x = (t+1)./(t-1);
y = (t^2+2)./(t^2-t);
% Find horizontal asymptotes
syms x0
tx = solve(x == x0, t);
num_ha = 0;
sh = [];
for id = 1:length(tx)
yx = subs(y, t, tx(id));
for s = 0:1
infi = (-1)^s*inf;
ya = limit(yx, x0, infi);
if isfinite(ya)
fprintf('Tiem can ngang la: y = %f\n', ya)
num_ha = num_ha + 1;
end
end
end
fprintf('Do thi ham f(x) co %d tiem can ngang\n------------------\n', num_ha)
% Find slant asymptotes
num_sa = 0;
ss = [];
for id = 1:length(tx)
yx = subs(y, t, tx(id));
for s = 0:1
infi = (-1)^s*inf;
a = limit(yx/x0, x0, infi);
b = limit(yx - a*x0, x0, infi);
c = [a b];
if isfinite(a) && isfinite(b)
new = 1;
for k = 1:size(ss, 1)
if all(c == ss(k, :))
new = 0;
break
end
end
if new
ss = [ss; c];
fprintf('Tiem can xien la: y = x * %f + %f\n', a, b)
num_sa = num_sa + 1;
end
end
end
end
fprintf('Do thi ham f(x) co %d tiem can xien\n-------------------\n', num_sa)
% Find vertical asymptotes
syms y0
ty = solve(y == y0, t);
num_va = 0;
sv = [];
for s = 0:1
infi = (-1)^s * inf;
ti = subs(ty, y0, infi);
for id = 1:length(ti)
t0 = ti(id);
if ~isreal(t0)
continue
end
xa = limit(x, t, t0);
if isfinite(xa)
new = 1;
for k = 1:size(sv, 1)
if xa == sv(k)
new = 0;
break
end
end
if new
sv = [sv xa];
fprintf('Tiem can dung la: x = %f\n', xa)
num_va = num_va + 1;
end
end
end
end
fprintf('Do thi ham f(x) co %d tiem can dung\n-------------------\n', num_va)
figure
hold on
fplot(x, y)
xlabel('Ox')
ylabel('Oy')
grid on
1 个评论
John D'Errico
2023-12-1
编辑:John D'Errico
2023-12-1
Please don't keep on reposting your question. I closed it as a pure duplicate.
As I said in my answer, your question is not even a question about MATLAB. Until you know how to approach a problem, you cannot write code to solve it. There is no tool in MATLAB to solve your problem.
回答(2 个)
John D'Errico
2023-11-25
编辑:John D'Errico
2023-11-25
Its an interesting question of mathematics, maybe not really a question about MATLAB in my eyes, because until you know how to solve a problem using mathematics, you cannot hope to write code.
Is there any function? No. Sorry, but I don't see any way to do so, since x and y can be literally anything. And since they could be arbitraily complicated, messy functional forms, it might even be possible to find some pair of functions where we cannot prove that an asymptote exists or not.
You have made an interesting attempt at a solution, where you look for points where x or y approach infinity, but I could counter with examples where x or y go to infinity at infinitely many points.
0 个评论
Walter Roberson
2023-12-1
syms t;
x_t = (t+1)./(t-1);
y_t = (t^2 + 2)./(t^2 - t);
limit(y_t, t, -inf)
limit(y_t, t, 0, 'left')
limit(y_t, t, 0, 'right')
limit(y_t, t, 1, 'left')
limit(y_t, t, 1, 'right')
limit(y_t, t, inf)
1 个评论
John D'Errico
2023-12-1
But this does not answer the question of how to identify a possibly linear asymptote. Or what to do if you cannot easily identify poles of the functions for a completely general problem.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrices and Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!