Plot a vector field from a matrix
16 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Samuel Curé
el 15 de Dic. de 2020
Respondida: Asad (Mehrzad) Khoddam
el 15 de Dic. de 2020
I would like to plot a field of unit vectors on a square lattice Λ of size
.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/461845/image.png)
Each point of the lattice is a unit vector pointing in some angle:
where θ is a matrix whose entries are between 0 and
.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/461850/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/461855/image.png)
Here is my attempt:
N=100
theta=2*pi*rand(N,N) % random for this example only
[X,Y]=meshgrid(1:N,1:N)
U=cos(theta)
V=sin(theta)
quiver(X,Y,U,V)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/461860/image.png)
However this is not very esthetic, how could I make this vector field more readable?
(Even when I choose a configuration where all spins are aligned, it is still not readable)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/461865/image.png)
Perhaps spacing the arrows and making them bigger with a longer shaft could make it more readable? I am quite new on MATLAB and I have no idea how to change this. Plotting this from my matrix theta felt already like an accomplishement.
Thank you for your help and your time.
0 comentarios
Respuesta aceptada
Asad (Mehrzad) Khoddam
el 15 de Dic. de 2020
You can use a scale like this:
N=100;
theta=2*pi*rand(N,N); % random for this example only
[X,Y]=meshgrid(1:N,1:N);
U=cos(theta);
V=sin(theta);
quiver(X,Y,U,V,0.3)
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre 2-D and 3-D Plots 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!