vector sum and magnitude

I need to create a function that will take two 3D geometric vectors as its arguments, sums them, and returns the resultant vector and its magnitude

2 Comments

Geoff
Geoff on 16 May 2012
And your question is ..... ?
Your statement is contradicting. If the values are in 1 dimension then it is a vector, if the values are in 2 dimensions then it is a matrix and if the values are in 3 or more dimensions then it is a tensor. So, 3D vector does not make any sense.

Sign in to comment.

Answers (1)

Geoff
Geoff on 16 May 2012
Maybe this will help:
function [vec, mag] = DoMyHomeworkForMe( v1, v2 )
% Your calculation goes here
end

10 Comments

Robert
Robert on 16 May 2012
:) hahaha nice
Robert
Robert on 16 May 2012
how about a push in the right direction
Geoff
Geoff on 16 May 2012
That WAS a push in the right direction. =P All you need to do is add your vectors together and find out how big the result is.
Robert
Robert on 16 May 2012
but how do i create a function that does so?
Geoff
Geoff on 16 May 2012
Now we're going round in circles! Please see the code in my answer. The INPUTS are v1 and v2; the OUTPUTS are vec and mag. I think the names a self-explanatory here. You don't have to use the function name that I used.
Robert
Robert on 16 May 2012
function addtwo(x,y)
% addtwo(x,y)
% print the result = x + y
x+y
how do i allow x and y to be a vector?
Geoff
Geoff on 16 May 2012
x = [1, 2, 3];
y = [2, 2, 2];
Robert
Robert on 16 May 2012
unbalanced or misused () or []
(thanks for helping me by the way)
Geoff
Geoff on 16 May 2012
You're kidding... copy that exact code I wrote declaring two vectors (x and y) and paste it into MatLab.
Robert
Robert on 16 May 2012
i was copying it wrong! sorrrrryyy

Sign in to comment.

Categories

Find more on MATLAB in Help Center and File Exchange

Tags

Asked:

on 16 May 2012

Commented:

on 1 Jun 2018

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!