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

汇编语言之源程序

一文看懂推荐系统:召回06:双塔模型——模型结构、训练方法,召回模型是后期融合特征,排序模型是前期融合特征

金仓数据库 KingbaseES V8 GIS数据迁移方案(3. 基于ArcGIS平台的数据迁移到KES)

01 【前言 基础使用 核心概念】

Xunrui cms website cannot be displayed normally after relocation and server change

如何发现一个有价值的 GameFi?

海量服务实例动态化管理

Utilities 
【MySQL系列】- LIKE查询 以%开头一定会让索引失效吗

如何基于OpenVINO POT工具简单实现对模型的量化压缩
随机推荐
MySQL3
01 【前言 基础使用 核心概念】
如何创建rpm包
IJCAI2022 | DictBert:采用对比学习的字典描述知识增强的预训练语言模型
PHP技能评测
"Dilili, wait for the lights, wait for the lights", the prompt sound for safe production in the factory
[Endnote] Word inserts a custom form of Endnote document format
PHP Skills Assessment
Log an error encountered when compiling google gn "I could not find a ".gn" file ..."
【Word】Word公式导出PDF后出现井号括号#()错误
ARM Mailbox
Understand the recommendation system in one article: Recall 06: Two-tower model - model structure, training method, the recall model is a late fusion feature, and the sorting model is an early fusion
使用OpenVINO实现飞桨版PGNet推理程序
特殊矩阵的压缩存储
C学生管理系统 指定位置插入学生节点
海量服务实例动态化管理
<开发>实用工具
直播预告|30分钟快速入门!来看可信分布式AI链桨的架构设计
CMS website construction process
【MySQL series】- Does LIKE query start with % will make the index invalid?