Advertisement
MysterionCS

taylorsinTest

Jan 18th, 2021
1,310
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.60 KB | None | 0 0
  1. function [] = taylorsinTest(wh,prc);
  2. % wh = Anzahl der Wiederholungen für Test, prc = Anzahl der Iterationsschritte für taylorsin()
  3.     P = zeros(wh,4);
  4.     for i = 1:wh
  5.         r = rand;
  6.         P(i,1) = 1;
  7.         P(i,2) = taylorsin(r,prc);
  8.         P(i,3) = sin(r);
  9.         P(i,4) = abs( P(i,2) - P(i,3) );
  10.     end
  11.     avg = 0;
  12.     for i = 1:wh
  13.         avg = avg + P(i,4);
  14.     end
  15.     avg = avg / wh;
  16.     for i = 1:wh
  17.         fprintf('%f\n',P(i,4));
  18.     end
  19.     formatSpec = 'Die durchschnittliche Abweichung beträgt %f\n';
  20.     fprintf(formatSpec,avg);
  21.     max = maxk(P(:,4),1);
  22.     formatSpec = 'Die größte Abweichung beträgt %f\n';
  23.     fprintf(formatSpec,max);
  24. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement