当前位置:网站首页>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);
边栏推荐
- 【OpenCV 图像处理2】:OpenCV 基础知识
- 关于#sql shell#的问题,如何解决?
- 程序员失眠时的数羊列表 | 每日趣闻
- CPDA|运营人如何从负基础学会数据分析(SQL)
- Exploding the circle of friends, Alibaba produced billion-level concurrent design quick notes are too fragrant
- 【存储】曙光存储DS800-G35 ISCSI各映射LUN给服务器
- “嘀哩哩,等灯等灯”,工厂安全生产的提示音
- Using OpenVINO to implement the flying paddle version of the PGNet inference program
- MySQL3
- leetcode-另一棵树的子树
猜你喜欢

【MySQL series】- Does LIKE query start with % will make the index invalid?

Jincang database KingbaseES V8 GIS data migration solution (3. Data migration based on ArcGIS platform to KES)

开篇-开启全新的.NET现代应用开发体验

【Endnote】Word插入自定义形式的Endnote文献格式

“嘀哩哩,等灯等灯”,工厂安全生产的提示音

KingbaseES V8 GIS数据迁移方案(2. Kingbase GIS能力介绍)

浅谈数据安全治理与隐私计算

如何基于OpenVINO POT工具简单实现对模型的量化压缩

刷爆朋友圈,Alibaba出品亿级并发设计速成笔记太香了
![Chapter 09 Use of Performance Analysis Tools [2. Index and Tuning] [MySQL Advanced]](/img/e7/61863c356e4c7bb03ba27865ee7be0.png)
Chapter 09 Use of Performance Analysis Tools [2. Index and Tuning] [MySQL Advanced]
随机推荐
A new technical director, who calls DDD a senior, is convinced
【LeetCode刷题】-数之和专题(待补充更多题目)
【PyQT5 绑定函数的传参】
Intel XDC 2022 Wonderful Review: Build an Open Ecosystem and Unleash the Potential of "Infrastructure"
回顾51单片机
Greenplum数据库故障分析——版本升级后gpstart -a为何返回失败
[Unity Entry Plan] Handling of Occlusion Problems in 2D Games & Pseudo Perspective
短域名绕过及xss相关知识
"Dilili, wait for the lights, wait for the lights", the prompt sound for safe production in the factory
开篇-开启全新的.NET现代应用开发体验
Live playback including PPT download | Build Online Deep Learning based on Flink & DeepRec
How do programmers without objects spend the Chinese Valentine's Day
Utilities 关于#sql shell#的问题,如何解决?
leetcode-对称二叉树
DAY22:sqli-labs 靶场通关wp(Less01~~Less20)
如何创建rpm包
How to deal with your own shame
【日常训练】1403. 非递增顺序的最小子序列
CPDA|运营人如何从负基础学会数据分析(SQL)