Invalid Message ID Format. Is my syntax wrong?

조회 수: 7 (최근 30일)
Mert Ayduman
Mert Ayduman 2016년 10월 24일
답변: Marc Jakobi 2016년 10월 24일
function area = areaof3ang(x1,y1,x2,y2,x3,y3)
if nargin~=6
error(message('You need to input 6 values for 3 points. As in x1,y1,x2,y2,x3,y3'));
end
area=abs((x1*(y2-y3) + x2*(y3-y1) + x3*(y1-y2))/2)
end
When I deliberately input 2 variable, it shows me this error.
Error using message
Invalid Message ID format: 'You need to input 6 values for 3 points. As in x1,y1,x2,y2,x3,y3'.
Error in areaof3ang (line 3)
error(message('You need to input 6 values for 3 points. As in x1,y1,x2,y2,x3,y3'))
What am I doing wrong?

채택된 답변

Marc Jakobi
Marc Jakobi 2016년 10월 24일
You do not need message() for that function.
function area = areaof3ang(x1,y1,x2,y2,x3,y3)
if nargin~=6
% this is sufficient:
error('You need to input 6 values for 3 points. As in x1,y1,x2,y2,x3,y3');
end
area=abs((x1*(y2-y3) + x2*(y3-y1) + x3*(y1-y2))/2)
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by