简体   繁体   中英

How to plot orientation and magnitude of a vector field in Matlab?

I'd like to plot a vector field with its orientation(I already know quiver could help) and jointly with its magnitude as a color plot. I saw another question Link where thery recommend to use HSV but I'd like to see the orientation with quiver jointly with the magnitude as a heat map.

Thanks for any help.

Assuming, that MagnitudeMat is an by m array with vector field magnistudes, positionsX and positionsY are vectors of length n and m respectively containing positions for MagnitudeMat values (vector placements), and uuu and vvv are n by m arrays with respectively x and y components of vectors:

% [1] prepare x and y axis data for drawing                             
[XXX,YYY] = meshgrid(positionsX,positionsY);
% [2] draw the heat map of magnitudes
imagesc(positionsX,positionsY,MagnitudeMat);  
hold on;
% [3] plot streamlines and arrows for vector field
hSlices = streamslice(XXX,YYY,uuu,vvv)
hSlices2 = quiver(XXX,YYY,uuu,vvv);
% [4] some graphical settings
set(hSlices,'LineWidth',1,  'Color' , [.5 .5 .5]);
set(hSlices2,'LineWidth',2, 'Color', [.3 .3 .3]);
colormap('hot');
colorbar('location','eastoutside')

I hope this example will help :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM