What is the difference between these two scripts; and which one is more appropriate to use
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
% 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 Commenti
Risposte (1)
Roger Stafford
il 18 Mar 2016
Modificato: Roger Stafford
il 18 Mar 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 Commenti
Roger Stafford
il 18 Mar 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'?
Vedere anche
Categorie
Scopri di più su 3-D Scene Control in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!