# Invalid Message ID Format. Is my syntax wrong?

12 visualizzazioni (ultimi 30 giorni)
Mert Ayduman il 24 Ott 2016
Risposto: Marc Jakobi il 24 Ott 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?
##### 0 CommentiMostra -1 commenti meno recentiNascondi -1 commenti meno recenti

Accedi per commentare.

### Risposta accettata

Marc Jakobi il 24 Ott 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
##### 0 CommentiMostra -1 commenti meno recentiNascondi -1 commenti meno recenti

Accedi per commentare.

### Categorie

Scopri di più su Logical in Help Center e File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by