XY MODEL COLOR MAP/PCOLOR

4 visualizaciones (últimos 30 días)
Oliver  Ford
Oliver Ford el 3 de Mayo de 2021
Comentada: Cris LaPierre el 3 de Mayo de 2021
I have code that uses Wolff's Algorithm to simulate the XY Model in MATLAB and I want to implement a pcolor/color map to demonstrate each spin according to their angles across the system. But I want it to be live and changing as the angles change.
Any idea how to do this?
This is an example of how I want it to look https://i.stack.imgur.com/aSp7s.png
(UPDATE: I think I'm essentially looking to color the arrows based on their angle of spin with a color bar to the side.)

Respuesta aceptada

Cris LaPierre
Cris LaPierre el 3 de Mayo de 2021
This looks like the HSV colormap.
I'm not sure what you have for data, but first thought is to use imagesc.
% create a matrix of data
theta = linspace(0,2*pi);
data = sin(theta).*cos(theta')*3;
% view as an image
imagesc(data)
colormap hsv
caxis([-3 3])
colorbar
Another option is to create a surface
figure
surf(data,'EdgeColor','none')
view(2)
colormap hsv
caxis([-3 3])
colorbar
  8 comentarios
Oliver  Ford
Oliver Ford el 3 de Mayo de 2021
I was after the color map to use the spins that the algorithm was using around line 81 in the loopupdate() function, and I believe with the color map was only mapping this:
theta = linspace(0,randi([2 6],1)*pi);
hence why the algorithm got confused with the two theta variables.
Thank you for your patience, how would I get the color map to use the theta from within that function, so use the the spin values that the system is using?
Cris LaPierre
Cris LaPierre el 3 de Mayo de 2021
I see your comment about just wanting to color the arrows. You create them using fill and plot, so you will have to look to what the acceptable inputs are for color for those functions.
The theta you point to is calculated once per iteration. You need the angle for every location in your X-Y grid. To use the image approach, you will need to build up a matrix of angles first, then use imagesc to view the matrix. A likely way to do this is to return the angle from the drawarrow function, and assign the value to a corresponding location in this matrix.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Blue 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!

Translated by