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에서 Cartesian Coordinate System Conversion에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by