What is the difference between these two scripts; and which one is more appropriate to use
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
% 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);
0 comentarios
Respuestas (1)
Roger Stafford
el 18 de Mzo. de 2016
Editada: Roger Stafford
el 18 de Mzo. de 2016
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 comentarios
Roger Stafford
el 18 de Mzo. de 2016
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'?
Ver también
Categorías
Más información sobre 3-D Scene Control en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!