Im having trouble creating a function that calculate two vectors

1 view (last 30 days)
  7 Comments
Jonathan
Jonathan on 27 Oct 2014
this is what i have so far.
function D = arevol (B)
  1. * # v1 = B(1,2) - B(1,1); %x2 - x1
  2. * # v2 = B(1,3) - B(1,2);% x3 - x2
  3. * # v3 = B(1,4) - B(1,3);% x4 - x3
  4. * #
  5. * # D = [v1 v2 v3] % Vectors
  6. B = [-10 10 3 4];
  7. x = arevol (B);
  8. trapz(B) % takes an aproximate intergration to find the area.
Geoff Hayes
Geoff Hayes on 27 Oct 2014
x1 and x2 (etc.) are vectors, so you should be subtracting columns to get your vectors v1 and v2.
v1 = B(:,2) - B(:,1); %x2 - x1

Sign in to comment.

Answers (0)

Categories

Find more on Just for fun in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!