How to plot vectors exactly on the edge of another graph?

1 Ansicht (letzte 30 Tage)
Niklas Kurz
Niklas Kurz am 15 Okt. 2021
Kommentiert: Niklas Kurz am 17 Okt. 2021
The best I've got is expressed by the following:
clear
[u,v] = meshgrid(-2:0.2:2);
f = u.^2+v.^2-1;
[du,dv] = gradient(f);
hold all
g = @(a,b) a.^2+b.^2-1;
fimplicit(g)
D1 = u.^2+v.^2 >1;
D2 = u.^2+v.^2 <1.5;
v(~D1) = NaN;
u(~D2) = NaN;
norm = norm(gradient(f));
quiver(u,v,du./norm,dv./norm,'Color','r')
axis equal
However, the vectors are close to the edge, but not right originating from there. I can't think a straight way around it.

Akzeptierte Antwort

Matt J
Matt J am 15 Okt. 2021
Bearbeitet: Matt J am 15 Okt. 2021
t=linspace(0,360,91); t(end)=0;
u=cosd(t);
v=sind(t);
fimplicit(@(a,b) a.^2+b.^2-1);hold on
quiver(u,v,u,v,'Color','r'); hold off
axis equal
  1 Kommentar
Niklas Kurz
Niklas Kurz am 17 Okt. 2021
Appreciated approch, using the outward second derivat of a circle parametrization.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Vector Fields finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by