Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
ME3255S2017/lecture_05/my_function.m
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
21 lines (17 sloc)
624 Bytes
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
function [vx,vy] = my_function(x,y,t) | |
% Help documentation of "my_function" | |
% This function computes the velocity in the x- and y-directions given | |
% three vectors of position in x- and y-directions as a function of time | |
% x = x-position | |
% y = y-position | |
% t = time | |
% output | |
% vx = velocity in x-direction | |
% vy = velocity in y-direction | |
vx=zeros(length(t),1); | |
vy=zeros(length(t),1); | |
vx(1:end-1) = diff(x)./diff(t); % calculate vx as delta x/delta t | |
vy(1:end-1) = diff(y)./diff(t); % calculate vy as delta y/delta t | |
vx(end) = vx(end-1); | |
vy(end) = vy(end-1); | |
end |