Matlabquiver 函数⽤法-画⽮量箭头图提要:
quiver (x, y,u,v)在点(x,y)处画(u,v)所定义的向量箭头。x,y,u,v必须是维度和元素数都⼀样的矩阵。如果是⼀维数组的话,x,y,u,v的元素数必须⼀致。quiver函数会⾃动调整箭头的长度以适应显⽰
quiver(x,y,u,v,scale)scale ⽤于限定箭头的长度,如果scale = 1 则等值显⽰⽮量的长度,⽽scale = 0.2 则显⽰0.2倍的⽮量长度。quiver(u,v)在x-y平⾯上均匀地画箭头图
quiver(x,y,u,v,LinSpec)⽤于限定箭头的属性,⽐如颜⾊,线型等。
quiver就是“箭筒,箭套”的意思
quiver⽤于画⽮量函数的箭头图(也叫速度图)(quiver plot, velocity vector plot)
举⼀个⽮量函数的例⼦:
如下图,你可以把这个函数看作位置⽮量 ,图中每⼀个箭头的⽅向都是向径(即从原点出发的⼀条直线),并且它的长度等于它到原点的距离。
quiver (x, y,u,v)在点(x,y)处画(u,v)所定义的向量箭头。x,y,u,v必须是维度和元素数都⼀样的矩阵。如果是⼀维数组的话,x,y,u,v的元素数必须⼀致。quiver函数会⾃动调整箭头的长度以适应显⽰。老子是什么学派
=F x +i y
j r
刘梓辰
%% draw the velocity vector arrow of the vector function i*x + j*y
% generate grids in a sub-definition area
clc
x = -1:0.5:1;
y = -1:0.5:1;
% generate the function values
u = x;
v = y;
% draw vector arrow graph
quiver(x, y, u, v)
text(0.5, 0, '$\leftarrow \vec{F}=\vec{i}x + \vec{j}y $', 'HorizontalAlignment', 'left', 'Interpreter', 'latex', 'FontSize', 15);
grid on
axis equal
提肛有什么好处quiver(x,y,u,v,scale)scale ⽤于限定箭头的长度,如果scale = 1 则等值显⽰⽮量的长度,⽽scale = 0.2 则显⽰0.2倍的⽮量长度。⽐如以上的代码,若加⼊scale参数,则输出图像如下:
%% draw the velocity vector arrow of the vector function i*x + j*y
% generate grids in a sub-definition area
clc
x = -1:0.5:1;
y = -1:0.5:1;
% generate the function values
u = x;
v = y;
% draw vector arrow graph
scale = 0.2
quiver(x, y, u, v,scale)
text(0.5, 0, '$\leftarrow \vec{F}=\vec{i}x + \vec{j}y $', 'HorizontalAlignment', 'left', 'Interpreter', 'latex', 'FontSize', 15);
grid on
axis equal
海底两万里好词好句quiver(u,v)在x-y平⾯上均匀地画箭头图
⽐如函数使⽤quiver(x,y,u,v,scale)书写代码:
%% draw the velocity vector arrow of the vector function (i*y + j*x)/sqrt(x^2 + y^2)
% generate grids in a sub-definition area
clc
R = 2:2:6;
theta = -pi:pi/4:pi;
x = R'*cos(theta);
y = R'*sin(theta);
% generate the function values
rr = sqrt(x.^2 + y.^2);
fx = -y./rr;
fy = x./rr;
%[FX,FY] = meshgrid(fx,fy);
% draw vector arrow graph
scale = 0.2;
quiver(x, y, fx, fy,scale)
text(4, 2, '$\vec{F}=\frac{ -\vec{i}y+\vec{j}x}{\sqrt{x^{2}+y^{2}} } $', 'HorizontalAlignment', 'left', 'Interpreter', 'latex', 'FontSize', 15);grid on
axis equal
=F x +y
22−y +x
i j
输出的图像为
带雪字的女孩名字⽽我们⽤quiver(u,v)替换掉quiver(x,y,u,v,scale),代码变为:
闭幕式致辞%% draw the velocity vector arrow of the vector function (i*y + j*x)/sqrt(x^2 + y^2)
% generate grids in a sub-definition area
clc
R = 2:2:6;
theta = -pi:pi/4:pi;
x = R'*cos(theta);
y = R'*sin(theta);兔子的耳朵像什么
% generate the function values
rr = sqrt(x.^2 + y.^2);
fx = -y./rr;
fy = x./rr;
icu出科小结%[FX,FY] = meshgrid(fx,fy);
% draw vector arrow graph
scale = 0.2;
quiver(fx, fy,scale)
text(4, 2, '$\vec{F}=\frac{ -\vec{i}y+\vec{j}x}{\sqrt{x^{2}+y^{2}} } $', 'HorizontalAlignment', 'left', 'Interpreter', 'latex', 'FontSize', 15); grid on
axis equal
输出的箭头图不再是环形分布,⽽变成x-y平⾯上的均匀分布:
quiver(x,y,u,v,LinSpec)⽤于限定箭头的属性,⽐如颜⾊,线型等。
⽰例代码:
%% draw the velocity vector arrow of the vector function (i*y + j*x)/sqrt(x^2 + y^2)
% generate grids in a sub-definition area
clc
R = 2:2:6;
theta = -pi:pi/4:pi;
x = R'*cos(theta);
y = R'*sin(theta);
% generate the function values
rr = sqrt(x.^2 + y.^2);
fx = -y./rr;
fy = x./rr;
%[FX,FY] = meshgrid(fx,fy);
% draw vector arrow graph
scale = 0.2;
quiver(x, y, fx, fy,scale,'.r')
text(4, 2, '$\vec{F}=\frac{ -\vec{i}y+\vec{j}x}{\sqrt{x^{2}+y^{2}} } $', 'HorizontalAlignment', 'left', 'Interpreter', 'latex', 'FontSize', 15); grid on
axis equal