当前位置:网站首页>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);
边栏推荐
- 刷爆朋友圈,Alibaba出品亿级并发设计速成笔记太香了
- dotnet 6 为什么网络请求不跟随系统网络代理变化而动态切换代理
- 力扣-二叉树的最大的深度
- 2022杭电多校第一场
- AI+小核酸药物|Eleven完成2200万美元种子轮融资
- SuperMap iDesktop.Net之布尔运算求交——修复含拓扑错误复杂模型
- Intel XDC 2022 Wonderful Review: Build an Open Ecosystem and Unleash the Potential of "Infrastructure"
Utilities - 如何看待自己的羞愧感
- Amazon Cloud Technology joins hands with Thundersoft to build an AIoT platform for industry customers
猜你喜欢
![[Endnote] Word inserts a custom form of Endnote document format](/img/70/e8a6f15b80e9c53db369fd715e51df.png)
[Endnote] Word inserts a custom form of Endnote document format

SuperMap iDesktop.Net之布尔运算求交——修复含拓扑错误复杂模型

Using OpenVINO to implement the flying paddle version of the PGNet inference program

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

【Unity入门计划】2D游戏中遮挡问题的处理方法&伪透视

树形查找(二叉查找树)

01 【前言 基础使用 核心概念】
![[Redis] Redis installation under Linux](/img/84/7791a87ff976be15b455f6ddc05bf2.png)
[Redis] Redis installation under Linux

为什么他们选择和AI恋爱?

.Net C# 控制台 使用 Win32 API 创建一个窗口
随机推荐
为什么他们选择和AI恋爱?
原生js实现多选框全部选中和取消效果
(17) 51 MCU - AD/DA conversion
Opening - Open a new .NET modern application development experience
HOG feature study notes
Amazon Cloud Technology joins hands with Thundersoft to build an AIoT platform for industry customers
迁移学习——Joint Geometrical and Statistical Alignment for Visual Domain Adaptation
“嘀哩哩,等灯等灯”,工厂安全生产的提示音
居民用水问题
js中try...catch和finally的用法
迅睿cms网站搬迁换了服务器后网站不能正常显示
fragment可见性判断
hypervisor相关的知识点
Greenplum Database Fault Analysis - Can a Soft Connection Be Made to the Database Base Folder?
ExcelPatternTool: Excel表格-数据库互导工具
DAY22:sqli-labs 靶场通关wp(Less01~~Less20)
浅谈数据安全治理与隐私计算
ARM Mailbox
汇编语言之源程序
2022杭电多校第一场