What is the difference between these two scripts; and which one is more appropriate to use

2 次查看(过去 30 天)
% the dataset is *u = squeeze(tdata(1,:,:)./10); v = squeeze(tdata(2,:,:)./10);*
%1st
nu = u.*cos(rlong) + v.*sin(rlong);
nv = -u.*sin(rlong) + v.*cos(rlong);
R = sqrt(nu.*nu + nv.*nv);
% 2nd
[TH,R] = cart2pol(v,u);
D = rad2deg(TH);

回答(1 个)

Roger Stafford
Roger Stafford 2016-3-18
编辑:Roger Stafford 2016-3-18
In "u = squeeze(tdata(1,:,:)./10);" the first level of the first dimension of three-dimensional 'tdata' is divided by 10 and converted into a two dimensional matrix. The 'v' is the same for the second level of that first dimension.
In the second pair, the coordinate axes for the point (u,v), (or rather the matrices of points,) is rotated counterclockwise by radian angle 'rlong' and (nu,nv) are the coordinates with respect to these new axes. The third equation gives the euclidean distance of the points from the origin.
In the third pair the first of the pair converts each of those original cartesian coordinates into polar coordinates. The second changes each of the angles in the polar coordinates from radian measure to degree measure. (It would appear the cartesian coordinates here are in reverse order.)
Asking which is the more appropriate is a meaningless question in this context. They all act together as a unified whole.
An alternate interpretation of the second pair is that all the points have been rotated clockwise by radian angle 'rlong' and (nu,nv) are their rotated cartesian coordinates with respect to the original axes.
  3 个评论
Roger Stafford
Roger Stafford 2016-3-18
Your equations only make sense if u and v are cartesian components of velocity vectors, not vectors themselves. But if all you want is the magnitude of each velocity vector, why not just do this:
R = sqrt(u.^2+v.^2);
It would give you a matrix of magnitudes. Why bother with rotations and 'cart2pol'?
Sophia
Sophia 2016-3-18
编辑:Sophia 2016-3-18
The dataset i am using says in its description, here is the link
https://nsidc.org/data/docs/daac/nsidc0116_icemotion.gd.html
Here are the details of the projection-
https://nsidc.org/data/ease/ease_grid.html
The reason why i need to do this, because u and v values change with the change in hemisphere. i.e. from W to E, cuz of the EASE Grid Projection

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 3-D Scene Control 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by