Why doesn't this file work?

조회 수: 5 (최근 30일)
Aidan O'Reilly
Aidan O'Reilly 2011년 3월 21일
function [lengths, angles, area] = vectors(A,B,C)
lengths=[norm(C-B), norm(A-C), norm(A-B)];
angles = [acosd(dot(A-B,A-C)/norm(A-B)*norm(A-C)) acosd( dot(B-A,B-C)/norm(B-A)*norm(B-C)),acosd(dot(C-A,C-B)/norm(C-A)*norm(C-B))];
end
This gives me the right answers for lengths when I put in vectors([1,2,-1],[3,4,0],[9,-2,7]), but it's not giving anything for angles, not even an error message.
  댓글 수: 1
Andrew Newell
Andrew Newell 2011년 3월 21일
Please format the code so it is readable (one line per command, indent two spaces).

댓글을 달려면 로그인하십시오.

채택된 답변

Matt Fig
Matt Fig 2011년 3월 21일
How are you calling the function? You need to call a multiple return argument function with multiple return args:
[LEN, ANG] = vectors([1,2,-1],[3,4,0],[9,-2,7])
And please, format the code in your question!
.
.
.
EDIT
By calling your function I mean, from the command line (the MATLAB window as you call it), put what I put above, then hit return. You will get two variables out when you do this. See my comment below to re-iterate.
  댓글 수: 21
Aidan O'Reilly
Aidan O'Reilly 2011년 3월 23일
Thanks, I'll definitely check that out. Wow, that's really encouraging. Have you used many other types of maths software? This is the only one I've be introduced to, but I don't know how widely Matlab is used within companies.
Walter Roberson
Walter Roberson 2011년 3월 23일
There is a fairly wide variety of software packages that overlap with Matlab and related packages. See in part, http://en.wikipedia.org/wiki/Computer_algebra_system

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Mathematics에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by