MysterionCS

poly_flaeche

Jan 18th, 2021
509
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function A = poly_flaeche(P,anzKnoten)
  2.     [r,c] = size(P);
  3.     n = r - 1;
  4.     A = 0;
  5.     for i = 1:n
  6.     % Erste Klammer A (x-Teil)
  7.     AK1 = ( P(i,1) - P(i+1,1) );
  8.     % Zweite Klammer A (y-Teil)
  9.     AK2 = ( P(i,2) +  P(i+1,2) );
  10.     % Formel Flächeninhalt
  11.     A = A + (0.5 * AK1 * AK2);
  12.     end
  13.     formatSpecA = 'Der Flächeninhalt des Polygons beträgt %f\n';
  14.     fprintf(formatSpecA,A);
  15. end
RAW Paste Data