当前位置:网站首页>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);
边栏推荐
猜你喜欢

英特尔 XDC 2022 精彩回顾:共建开放生态,释放“基建”潜能

Live preview | 30 minutes started quickly!Look at credible distributed AI chain oar architectural design

Intel XDC 2022 Wonderful Review: Build an Open Ecosystem and Unleash the Potential of "Infrastructure"

迁移学习——Distant Domain Transfer Learning

MySQL学习

迅睿cms网站搬迁换了服务器后网站不能正常显示

MySQL3

直播预告|30分钟快速入门!来看可信分布式AI链桨的架构设计

J9数字货币论:web3的创作者经济是什么?

迁移学习——Joint Geometrical and Statistical Alignment for Visual Domain Adaptation
随机推荐
超越YOLO5-Face | YOLO-FaceV2正式开源Trick+学术点拉满
树表的查找
<开发>实用工具
Object.defineProperty实时监听数据变化并更新页面
基于OpenVINO工具套件简单实现YOLOv7预训练模型的部署
特殊矩阵的压缩存储
为什么他们选择和AI恋爱?
hypervisor相关的知识点
Jincang database KingbaseES V8 GIS data migration solution (3. Data migration based on ArcGIS platform to KES)
迅睿cms网站搬迁换了服务器后网站不能正常显示
第09章 性能分析工具的使用【2.索引及调优篇】【MySQL高级】
海量服务实例动态化管理
Domain Driven Design - MDD
ARM Mailbox
Chapter 09 Use of Performance Analysis Tools [2. Index and Tuning] [MySQL Advanced]
How to deal with your own shame
Tree search (bintree)
Programmer's list of sheep counting when insomnia | Daily anecdote
1349. 参加考试的最大学生数 状态压缩
Short domain name bypass and xss related knowledge