How to perform a coordinate transformation in a function?
26 次查看(过去 30 天)
显示 更早的评论
I want to perform a coordinate transformation on a ds square. I have never used MatLab before. I have entered the original expression, I will enter how the new coordinates depend on the original ones. Here I get stuck: how should I tell it to substitute into the ds square function?
3 个评论
John D'Errico
2023-12-24
This is not a question about knowing MATLAB, but a question of understanding what a coordinate transform means, and how you would "apply" such a thing.
For example, suppose you have coordinates, (x,y). Then you might wish to convert to polar coordinates. That is a coordinate transform. You can do so by a simple set of equations, or you can use the cart2pol function in MATLAB.
Even more simply, given coordinates (x,y), then the pair (x+1,y+2) is a coordinate transform, a simple translational one.
The problem is, we have no idea what you are doing, what transformation you would employ, or how you would use it in code. I could see cases where you might use the coordinate transform in a purely mathematical way, so before you write any code at all. Or it might become an essential part of your code.
You need to be far more clear if you want a useful answer.
采纳的回答
David Goodmanson
2023-12-24
Hi Kovacs
Here is one way. Clearly
x^2 + t^2 = xi^2
by inspection, so that factor, which is common to both terms, can be saved till the end.
syms x t xi lam dxi dlam
x = xi*cos(lam)
t = xi*sin(lam)
dx = diff(x,lam)*dlam + diff(x,xi)*dxi
dt = diff(t,lam)*dlam + diff(t,xi)*dxi
ds2 = simplify((1/xi^2)*((-dt^2+dx^2)*(x^2-t^2) +4*x*t*(dx*dt)))
ds2 = - dlam^2*xi^2 + dxi^2
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Special Values 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!