当前位置:网站首页>Matlab drawing - points and vectors: method and source code of vector addition and subtraction
Matlab drawing - points and vectors: method and source code of vector addition and subtraction
2022-07-28 01:11:00 【Franklin】
Preface :
Some blogs just turn Matlab In Chinese , But his explanation , He himself said it was not quite right .

This paper starts from practice , Detailed introduction Matlab Yes
Drawing method of points and vectors in coordinate space .
1 Concept and drawing method of point :
1.1 A point on a plane

plot(2, 3, '.', 'MarkerSize', 16,"Color",'r');【 case 】, In this case , Draw a red dot , Coordinates are in Cartesian coordinates (2,3).
1.2 A point in space :

fig1 = figure(1)
plot3(1, 2,3, '.', 'MarkerSize', 16,"Color",'r')1.3 In a space 2 A little bit :

fig1 = figure(1)
plot3(1, 2,3, '.', 'MarkerSize', 16,"Color",'r')
hold on
plot3(4, 5,6, '.', 'MarkerSize', 16,"Color",'b')The concept of vector :
2 How to draw vectors :
2.1 Drawing of a two-dimensional vector :

The code draws three vectors with different starting points ,
fig1 = figure(1)
scale = 1;
quiver(0,0,2,3,scale,'b');
grid on;
hold on;
quiver(1,1,2,3,scale,'g');
grid on;
hold on;
quiver(4,1,2,3,scale,'r');
grid on;
% The first two numbers represent the starting coordinates of the two-dimensional vector
% The last two numbers represent the endpoint coordinates of the two-dimensional vector
% scale=1 It means that the length of the vector is not expanded
% 'b' Representing blue 2.2 The rendering of a three-dimensional vector :

scale = 1;
quiver3(0,0,0,1,1,1,scale,'b');
hold on;
quiver3(1,1,0,1,1,1,scale,'r');
hold on;
quiver3(6,1,0,1,1,1,scale,'g');
% The first three numbers represent the starting coordinates of the three-dimensional vector
% The last three numbers represent the end coordinates of the three-dimensional vector 2.3 Drawing of vector addition and subtraction :
2.3.1
Dimensionally

fig1 = figure(1)
scale = 1;
quiver(0,0,2,3,scale,'b');
grid on;
hold on;
quiver(2,3,1,3,scale,'g');
grid on;
hold on;
quiver(0,0,2+1,3+3,scale,'r');
grid on;2.3.2

scale = 1;
quiver3(0,0,0,1,1,1,scale,'b');
hold on;
quiver3(1,1,1,2,2,0,scale,'r');
hold on;
quiver3(0,0,0,3,3,1,scale,'g');3 The use of reference :
1 function :quiver And the drawing of vector field
quiver(X,Y,U,V) plots arrows with directional components U and V at the Cartesian coordinates specified by X and Y.【X,Y Vector At the beginning of Descartes , The horizontal movement unit multiple of the vector is U, The vertical movement unit multiple is V】【 case , An important concept in the understanding of vectors is instruction, It refers to the number of unit coordinate steps of each coordinate component of the vector 】
For example, the first arrow originates from the point X(1) and Y(1), extends horizontally according to U(1), and extends vertically according to V(1). By default, the quiver function scales the arrow lengths so that they do not overlap.
【quiver Functions seem to follow this rule , The following explanation also verifies this paragraph , from (1,1) As a starting point , Then extend vertically 【 Move 】 A unit v(1), Then extend a unit horizontally U(1), Of course. , Avoid vector arrows overlapping , He i Automatically scale overlapping vectors , This paragraph has not yet found a suitable example to verify the practice 】
【 Official website , An example of drawing vector graph is given , Draw a vector diagram of North American wind speed 】
load wind.mat;
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);
quiver(X,Y,U,V)
axis equalIt's used here wind.mat Open source data :【 This is introduced in the next section of this article 】
【Franklin case , Here we choose No 11 To 22 That's ok ,11 To 22 Column position sensor 1 Location and wind speed data , And then call quiver Drawing , We can understand it as , Yes 12*12 A vector matrix composed of vectors 】

【 Here the length of the arrow , Is the length of the vector , It vividly shows the speed of the wind , meanwhile quiver Functions have the function of avoiding overlap , therefore , The length of some vectors should be adjusted 】
2 wind data
3-D data on air currents over North America. The data consists of (x,y,z) position components and (u,v,w) velocity components.
File Size: 142 KB
Data Size: Six matrices of size 35-by-41-by-15
load wind.mat
【wind data It's a 3 Data set of dimensions , Is a data set of North American air flow , Include ,xyz A location element of , And a uvw Speed element of , Specifically wind Use of data , stay MT There is a very detailed explanation in a video introduction of wind energy 】
use MT load After the data , We saw it wind data The details of :
Is, indeed, 6 Matrix , Every matrix is 35-by-41-by-15

Let's first look at the location data x matrix ,Y matrix ,U matrix :
You can see the ,XYZ Matrix data of , On different lines X The value of is the same ,Y Values are different , however , stay Page The corresponding words on , It's all the same , Have reason to believe Page It's the sensor ID, There are about 15 A sensor .
then ,U,V The value of is the wind speed and other parameters measured by the sensor in different reverse directions , This data is quite random .
X Y U val(:,:,1) = val(:,:,5) = val(:,:,1) = val(:,:,10) = val(:,:,1) = val(:,:,2) = Column 1 Column 1 Column 1 Column 1 Column 1 Column 1 70.1879 70.1879 70.1879 70.1879 17.4999 17.4999 0.5685 -2.8479 70.1879 70.1879 18.7499 18.7499 0.5685 -2.8479 70.1879 70.1879 19.9999 19.9999 0.5685 -2.8479 70.1879 70.1879 21.2499 21.2499 0.8791 -2.2267 70.1879 70.1879 22.4999 22.4999 1.1897 -1.295 70.1879 70.1879 23.7499 23.7499 1.5003 -0.3632 70.1879 70.1879 24.9999 24.9999 1.5003 0.5685 70.1879 70.1879 26.2499 26.2499 2.1214 2.1214 70.1879 70.1879 27.4999 27.4999 3.0531 3.3637 70.1879 70.1879 28.7499 28.7499 4.606 6.1589 70.1879 70.1879 29.9999 29.9999 4.606 7.4013 70.1879 70.1879 31.2499 31.2499 4.9166 9.2647 70.1879 70.1879 32.4999 32.4999 4.9166 10.507 70.1879 70.1879 33.7499 33.7499 5.2272 13.9234 70.1879 70.1879 34.9999 34.9999 5.2272 15.4763 70.1879 70.1879 36.2499 36.2499 5.2272 15.4763 70.1879 70.1879 37.4999 37.4999 5.5378 17.0292 70.1879 70.1879 38.7499 38.7499 6.1589 20.135 70.1879 70.1879 39.9999 39.9999 5.5378 19.8244 70.1879 70.1879 41.2499 41.2499 3.3637 18.2715 70.1879 70.1879 42.4999 42.4999 1.5003 13.9234 70.1879 70.1879 43.7499 43.7499 0.8791 10.507 70.1879 70.1879 44.9999 44.9999 0.2579 5.2272 70.1879 70.1879 46.2499 46.2499 -0.6738 1.5003 70.1879 70.1879 47.4999 47.4999 -2.2267 -3.1584 70.1879 70.1879 48.7499 48.7499 -3.1584 -5.6431 70.1879 70.1879 49.9999 49.9999 -3.7796 -5.6431 70.1879 70.1879 51.2499 51.2499 -4.4008 -6.8854 70.1879 70.1879 52.4999 52.4999 -4.7113 -8.4383 70.1879 70.1879 53.7499 53.7499 -3.7796 -8.1277 70.1879 70.1879 54.9999 54.9999 -2.5373 -7.196 70.1879 70.1879 56.2499 56.2499 -1.295 -6.2642 70.1879 70.1879 57.4999 57.4999 -0.9844 -4.7113 70.1879 70.1879 58.7499 58.7499 -1.295 -3.1584 59.9999 59.9999 -2.5373 -2.8479
Column 2 Column 2 Column 2 Column 2 Column 2 Column 2 71.7907 71.7907 71.7907 71.7907 17.4999 17.4999 0.5685 -2.5373 71.7907 71.7907 18.7499 18.7499 0.5685 -2.5373 71.7907 71.7907 19.9999 19.9999 0.8791 -2.5373 71.7907 71.7907 21.2499 21.2499 0.8791 -1.6055 71.7907 71.7907 22.4999 22.4999 1.1897 -0.9844 71.7907 71.7907 23.7499 23.7499 1.5003 0.2579 71.7907 71.7907 24.9999 24.9999 1.1897 0.5685 71.7907 71.7907 26.2499 26.2499 2.1214 3.0531 71.7907 71.7907 27.4999 27.4999 3.6743 5.5378 71.7907 71.7907 28.7499 28.7499 3.3637 6.1589 71.7907 71.7907 29.9999 29.9999 3.3637 7.0907 71.7907 71.7907 31.2499 31.2499 4.2955 8.6436 71.7907 71.7907 32.4999 32.4999 4.9166 9.5753 71.7907 71.7907 33.7499 33.7499 5.2272 12.0599 71.7907 71.7907 34.9999 34.9999 5.5378 16.408 71.7907 71.7907 36.2499 36.2499 4.9166 17.3398 71.7907 71.7907 37.4999 37.4999 4.9166 16.408 71.7907 71.7907 38.7499 38.7499 4.606 16.7186 71.7907 71.7907 39.9999 39.9999 4.606 17.0292 71.7907 71.7907 41.2499 41.2499 4.2955 17.0292 71.7907 71.7907 42.4999 42.4999 0.5685 12.0599 71.7907 71.7907 43.7499 43.7499 1.5003 9.5753 71.7907 71.7907 44.9999 44.9999 0.8791 5.5378 71.7907 71.7907 46.2499 46.2499 0.2579 2.432 71.7907 71.7907 47.4999 47.4999 -1.6055 -2.8479 71.7907 71.7907 48.7499 48.7499 -2.5373 -5.3325 71.7907 71.7907 49.9999 49.9999 -2.8479 -5.6431 71.7907 71.7907 51.2499 51.2499 -2.8479 -6.2642 71.7907 71.7907 52.4999 52.4999 -3.469 -6.8854 71.7907 71.7907 53.7499 53.7499 -2.8479 -6.8854 71.7907 71.7907 54.9999 54.9999 -1.295 -6.2642 71.7907 71.7907 56.2499 56.2499 -0.6738 -4.4008 71.7907 71.7907 57.4999 57.4999 -2.2267 -3.1584 71.7907 71.7907 58.7499 58.7499 -2.8479 -3.7796 59.9999 59.9999 -2.8479 -2.8479
Reference resources :
Quiver or vector plot - MATLAB quiver (mathworks.com)
matlab The drawing method of vector in _ Chentengfei's blog -CSDN Blog _matlab Draw vector
Matlab Draw vector graph and plane graph - You know (zhihu.com)
边栏推荐
- Network equipment hard core technology insider firewall and security gateway chapter (VI) security double repair under the law
- Leetcode:1997. the first day after visiting all rooms [jump DP]
- 范德蒙德卷积 学习笔记
- 安全检测风险
- [300 opencv routines] 241. Scale invariant feature transformation (SIFT)
- CAP的理解
- Leetcode - find the median of two positively ordered arrays
- [introduction to C language] zzulioj 1026-1030
- Maximize activation
- "C language" deep entry rounding & four functions
猜你喜欢
随机推荐
C语言程序设计 | offsetof宏的讲解及其模拟实现
Tear the source code of gateway by hand, and tear the source code of workflow and load balancing today
Redis sentinel mode
多线程及多线程程序的编写
Can TSMC Samsung build a production line without American equipment for Huawei?
Analysis and recurrence of network security vulnerabilities
立即报名 | 云原生技术交流 Meetup 广州站已开启,8 月 6 号与你相遇!
文件系统的层次结构
110. SAP UI5 FileUploader 控件深入介绍 - 为什么需要一个隐藏的 iframe
R language evaluates the relative importance of the predictive factors (variables, characteristics) of the regression model, scales the predictive variables of the regression model, and then construct
Vandermond convolution learning notes
c# 反射之Type使用
Oracle error: ora-01722 invalid number
Maximize activation
分支和循环语句题目练习
接口测试实战项目02:读懂接口测试文档,上手操练
Examples of application of JMeter in performance testing
Leetcode:1997. the first day after visiting all rooms [jump DP]
7. Typescript part Foundation
Focus on demand flow rather than idle people
Dimensionally 
![[300 opencv routines] 241. Scale invariant feature transformation (SIFT)](/img/7a/a764c779c3162920c832325f89f340.png)







