Invalid Message ID Format. Is my syntax wrong?
7 次查看(过去 30 天)
显示 更早的评论
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?
0 个评论
采纳的回答
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 个评论
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!