# Matlab画曲线的切向量-quiver函数的应用

%% draw the fuction curve of y = sqrt(2 + x.^2) and its quiver plot
%drawn the function plot
x = -2:0.1:2;
y = sqrt(2 + x.^2);
plot(x,y);
text(-1.2, 2, '$\leftarrow y = \sqrt{x^2 + 1}$', 'HorizontalAlignment', 'left', 'Interpreter', 'latex', 'FontSize', 15);
hold on

% draw the quiver plot
fx = y;
fy = x;
scale = 0.2;
quiver(x,y,fx, fy,scale,'r','LineWidth',1)
text(0.5, 1.2, '$\vec{F}(x,y)=\vec{i}x + \vec{j}y$', 'HorizontalAlignment', 'left', 'Interpreter', 'latex', 'FontSize', 15);
axis equal
hold off

%%  draw the velocity vector arrow of the vector function i*y + j*x at its varisou interal function

x = -1:0.1:1; % x-axis for plotting
c = 0:0.25:1; % different integral constants

%create X,Y matrix for plottig
X = (x')*(ones(1,length(c)));
C = (ones(length(x),1))*c;
Y = sqrt(2.*C + X.^2);

plot(X,Y);
hold on
%% quiver plottting
fx = Y;
fy = X;
scale = 0.2;
quiver(X,Y,fx, fy,scale,'r')
text(-0.2, 1.6, '$\vec{F}(x,y)=\vec{i}y + \vec{j}x$', 'HorizontalAlignment', 'left', 'Interpreter', 'latex', 'FontSize', 15);
axis equal
grid on
hold off

%% draw the fuction curve of y = sqrt(2 + X.^2) and one of its tangential vectors
%drawn the function plot
x = -2:0.1:2;
y = sqrt(2 + x.^2);
plot(x,y);
text(-1.2, 2, '$\leftarrow y = \sqrt{x^2 + 1}$', 'HorizontalAlignment', 'left', 'Interpreter', 'latex', 'FontSize', 15);
hold on

% draw the tangential vecotr at position x(i),y(i), i = 25
fx = y;
fy = x;
scale = 0.5;
i = 25;
quiver(x(i),y(i),fx(i), fy(i),scale,'r','LineWidth',2)
text(1.2, 1.7, '$\vec{F}(x_{0},y_{0})$', 'HorizontalAlignment', 'left', 'Interpreter', 'latex', 'FontSize', 15);
axis equal
hold off

01-04
09-23
06-29 3万+
01-11 1万+
05-05 1万+
03-21 2153
08-03 3853
03-14 1万+
03-25 1万+
04-17 1713
05-26 3797