Invalid Message ID Format. Is my syntax wrong?

7 Ansichten (letzte 30 Tage)
Mert Ayduman
Mert Ayduman am 24 Okt. 2016
Beantwortet: Marc Jakobi am 24 Okt. 2016
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?

Akzeptierte Antwort

Marc Jakobi
Marc Jakobi am 24 Okt. 2016
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

Weitere Antworten (0)

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by