当前位置:网站首页>matlab绘制用颜色表示模值大小的箭头图
matlab绘制用颜色表示模值大小的箭头图
2022-08-05 02:15:00 【zdlwhereyougo】
matlab自带的quiver函数可以绘制箭头图,箭头的长度与向量的模值大小对应。如果想要实现箭头长度相同,首先要对箭头进行归一化,计算所有箭头的模值大小,计算出每个箭头的缩放系数,然后将垂直分量和水平分量进行缩放,使得所有箭头模值相等。然后将模值从大到小分为256个值,并使用matlab自带的colormap矩阵,依次对箭头上色。
直接看图:左边是原图,右边是调整后的图
源代码:
clc;close all;clear ;
%构造数据
load('wind','x','y','u','v')
X = x(11:22,11:22,1);
Y = y(11:22,11:22,1);
U = u(11:22,11:22,1);
V = v(11:22,11:22,1);
%% 默认绘图
figure
quiver(X,Y,U,V,'r')
%% 调节绘图
M=sqrt(U.^2+V.^2);%计算模量
colorlist=jet;%加载色条,也可以更换别的,cool ,winter等
Mdown=min(M(:));
Mup=max(M(:));
Mlist=linspace(Mdown,Mup,256);
scaler1=Mup./M;%长度调节因子
U=U.*scaler1;%每个分量进行调节
V=V.*scaler1;%每个分量进行调节
scaler2=0.05;%重新调节长度 以适应绘图
U=U*scaler2;
V=V*scaler2;
figure
[m,n]=size(X);
for i=1:m
for j=1:n
Mtemp=abs(M(i,j)-Mlist);
index=find(Mtemp==min(Mtemp));
colorarrow=colorlist(index,:);
q =quiver(X(i,j),Y(i,j),U(i,j),V(i,j),'MaxHeadSize',100);%每一个单独画,调节箭头大小
q.LineWidth=1;
q.Color=colorarrow;
hold on
end
end
hc=colorbar;
colormap(jet)
hc.TickLabels=linspace(Mdown,Mup,11);
边栏推荐
- 学习笔记-----左偏树
- SuperMap iDesktop.Net之布尔运算求交——修复含拓扑错误复杂模型
- EBS利用虚拟列及hint 提示优化sql案例一则
- Transfer Learning - Joint Geometrical and Statistical Alignment for Visual Domain Adaptation
- Oracle encapsulates restful interfaces into views
- Amazon Cloud Technology joins hands with Thundersoft to build an AIoT platform for industry customers
- [Redis] Redis installation under Linux
- 在这个超连接的世界里,你的数据安全吗
- How to deal with your own shame
- 英特尔 XDC 2022 精彩回顾:共建开放生态,释放“基建”潜能
猜你喜欢
LPQ(局部相位量化)学习笔记
金仓数据库 KingbaseES V8 GIS数据迁移方案(3. 基于ArcGIS平台的数据迁移到KES)
【Endnote】Word插入自定义形式的Endnote文献格式
source program in assembly language
如何基于OpenVINO POT工具简单实现对模型的量化压缩
海量服务实例动态化管理
LeetCode使用最小花费爬楼梯----dp问题
[Word] #() error occurs after Word formula is exported to PDF
Xunrui cms website cannot be displayed normally after relocation and server change
迅睿cms网站搬迁换了服务器后网站不能正常显示
随机推荐
英特尔 XDC 2022 精彩回顾:共建开放生态,释放“基建”潜能
STM32使用stm32cubemx LL库系列教程
ARM Mailbox
KingbaseES V8 GIS data migration solution (2. Introduction to the capabilities of Kingbase GIS)
Hypervisor related knowledge points
Fragment visibility judgment
Leetcode brushing questions - 22. Bracket generation
Live preview | 30 minutes started quickly!Look at credible distributed AI chain oar architectural design
dotnet 6 为什么网络请求不跟随系统网络代理变化而动态切换代理
How to deal with your own shame
多线程(2)
【Endnote】Word插入自定义形式的Endnote文献格式
How to create an rpm package
CPDA|运营人如何从负基础学会数据分析(SQL)
J9数字货币论:web3的创作者经济是什么?
亚马逊云科技 + 英特尔 + 中科创达为行业客户构建 AIoT 平台
树形查找(二叉查找树)
oracle将restful接口封装到视图中
优化Feed流遭遇拦路虎,是谁帮百度打破了“内存墙”?
Greenplum Database Fault Analysis - Can a Soft Connection Be Made to the Database Base Folder?