-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding python script to get average per date
- Loading branch information
Showing
10 changed files
with
19,384 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
1er_Semestre/Modelacion_computacional_del_movimiento/vectarrow.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
function vectarrow(p0,p1) | ||
%Arrowline 3-D vector plot. | ||
% vectarrow(p0,p1) plots a line vector with arrow pointing from point p0 | ||
% to point p1. The function can plot both 2D and 3D vector with arrow | ||
% depending on the dimension of the input | ||
% | ||
% Example: | ||
% 3D vector | ||
% p0 = [1 2 3]; % Coordinate of the first point p0 | ||
% p1 = [4 5 6]; % Coordinate of the second point p1 | ||
% vectarrow(p0,p1) | ||
% | ||
% 2D vector | ||
% p0 = [1 2]; % Coordinate of the first point p0 | ||
% p1 = [4 5]; % Coordinate of the second point p1 | ||
% vectarrow(p0,p1) | ||
% | ||
% See also Vectline | ||
|
||
% Rentian Xiong 4-18-05 | ||
% $Revision: 1.0 | ||
|
||
if max(size(p0))==3 | ||
if max(size(p1))==3 | ||
x0 = p0(1); | ||
y0 = p0(2); | ||
z0 = p0(3); | ||
x1 = p1(1); | ||
y1 = p1(2); | ||
z1 = p1(3); | ||
plot3([x0;x1],[y0;y1],[z0;z1]); % Draw a line between p0 and p1 | ||
|
||
p = p1-p0; | ||
alpha = 0.1; % Size of arrow head relative to the length of the vector | ||
beta = 0.1; % Width of the base of the arrow head relative to the length | ||
|
||
hu = [x1-alpha*(p(1)+beta*(p(2)+eps)); x1; x1-alpha*(p(1)-beta*(p(2)+eps))]; | ||
hv = [y1-alpha*(p(2)-beta*(p(1)+eps)); y1; y1-alpha*(p(2)+beta*(p(1)+eps))]; | ||
hw = [z1-alpha*p(3);z1;z1-alpha*p(3)]; | ||
|
||
hold on | ||
plot3(hu(:),hv(:),hw(:)) % Plot arrow head | ||
grid on | ||
xlabel('x') | ||
ylabel('y') | ||
zlabel('z') | ||
hold off | ||
else | ||
error('p0 and p1 must have the same dimension') | ||
end | ||
elseif max(size(p0))==2 | ||
if max(size(p1))==2 | ||
x0 = p0(1); | ||
y0 = p0(2); | ||
x1 = p1(1); | ||
y1 = p1(2); | ||
plot([x0;x1],[y0;y1]); % Draw a line between p0 and p1 | ||
|
||
p = p1-p0; | ||
alpha = 0.1; % Size of arrow head relative to the length of the vector | ||
beta = 0.1; % Width of the base of the arrow head relative to the length | ||
|
||
hu = [x1-alpha*(p(1)+beta*(p(2)+eps)); x1; x1-alpha*(p(1)-beta*(p(2)+eps))]; | ||
hv = [y1-alpha*(p(2)-beta*(p(1)+eps)); y1; y1-alpha*(p(2)+beta*(p(1)+eps))]; | ||
|
||
hold on | ||
plot(hu(:),hv(:)) % Plot arrow head | ||
grid on | ||
xlabel('x') | ||
ylabel('y') | ||
hold off | ||
else | ||
error('p0 and p1 must have the same dimension') | ||
end | ||
else | ||
error('this function only accepts 2D or 3D vector') | ||
end |
Binary file not shown.
Oops, something went wrong.