How to create a quiver plot with logarithmic scaled arrows
24 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Yoav Romach
am 7 Mär. 2016
Kommentiert: Yoav Romach
am 16 Mär. 2019
Hey, I have a vector field with a large dynamic range; therefore the only way to properly see it in a quiver plot is if the length of the vectors will scale logarithmic instead of linearly.
As far as I know, there is no built in way to do it. Manually take the log before calling quiver will not work as it will change the angles, and therefore the quiver plot will be wrong.
I tried searching online but couldn't a way to do it, anyone knows one?
Another option is starting with the matlab built in quiver plot code and manually making another function that fixes it, is there anyway to get it?
2 Kommentare
Chad Greene
am 7 Mär. 2016
Interesting problem. The code for quiver is viewable. Type
open quiver
and it should be relatively painless to manually hack the length scaling.
Akzeptierte Antwort
Star Strider
am 7 Mär. 2016
I’m not certain what you’re plotting, so I’m guessing here.
This is one approach:
t = linspace(1E-3, 6*pi);
x = t .* cos(t) + 2;
y = t.* sin(t) + 2;
dx = gradient(x);
dy = gradient(y);
figure(1)
quiver(x, y, dx, dy) % Retain Scaling
grid
axis equal
log_dx = log(hypot(dx,dy)) .* (dx);
log_dy = log(hypot(dx,dy)) .* (dy);
figure(2)
quiver(x, y, log_dx, log_dy, 0) % Log Arrows, No Scaling
grid
axis equal
6 Kommentare
Weitere Antworten (1)
Angelo Hafner
am 15 Mär. 2019
Bearbeitet: Angelo Hafner
am 15 Mär. 2019
Just enter the u,v,w components in the function log_cv... The function returns the log components of the vector [u,v,w]...
function [log_ax,log_ay,log_az] = log_cv(u,v,w)
r = sqrt(u.^2 + v.^2 + w.^2);
rho = sqrt(u.^2 + v.^2);
t = atan2(rho,w);
f = atan2(v,u);
log_ax = log10(r) .* sin(t) .* cos(f);
log_ay = log10(r) .* sin(t) .* sin(f);
log_az = log10(r) .* cos(t);
end
Siehe auch
Kategorien
Mehr zu Vector Fields finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!