Created
June 4, 2011 09:53
-
-
Save vertexclique/1007766 to your computer and use it in GitHub Desktop.
dot product
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 y = dot(a,b) | |
if length(a) == length(b) | |
size = length(a); | |
if size < 2 | |
error('The vectors size must greater than one'); | |
end; | |
else | |
error('Vectors size not equal each other'); | |
end; | |
total= 0; | |
for i= 1:size | |
total= total + ( a(i)*b(i) ); | |
end; | |
y = total; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment