Advertisement
Guest User

Untitled

a guest
Dec 5th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. function [outputArg1] = nullstelle(p,xL,xR)
  2. %UNTITLED2 Summary of this function goes here
  3. % Detailed explanation goes here
  4. h = abs (xR - xL);
  5. if polyval(p,xL)*polyval(p,xR) > 0
  6. disp(['Es gibt keine Nullstelle zwischen ' num2str(xL) ' und ' num2str(xR) ' oder das Intervall ist zu groß und es gibt eine gerade Anzahl der Nullstellen.'])
  7. elseif polyval(p,xL)*polyval(p,xR) < 0
  8. while h > 10^(-15)
  9. if polyval(p,xL)*polyval(p,0.5*(xL+xR)) < 0
  10. xR = 0.5*(xR+xL);
  11. h = abs (xR - xL);
  12. elseif polyval(p,xL)*polyval(p,0.5*(xL+xR)) > 0
  13. xL = 0.5*(xR+xL);
  14. h = abs (xR - xL);
  15. elseif polyval(p,xL)*polyval(p,0.5*(xL+xR)) == 0
  16. xL = 0.5*(xR+xL);
  17. xR = xL;
  18. h = 0;
  19. end
  20. end
  21.  
  22. disp(['Es gibt mindestens eine Nullstelle gleich : ' num2str(xL)]);
  23. elseif polyval(p,xL)*polyval(p,xR) == 0
  24. if polyval(p,xL) == 0
  25. disp(['Es gibt eine Nullstelle gleich ' num2str(xL)])
  26. elseif polyval(p,xR) == 0
  27. disp(['Es gibt eine Nullstelle gleich ' num2str(xR)])
  28. elseif polyval(p,xL) == 0 && polyval(p,xR) == 0
  29. disp(['Es gibt zwei Nullstellen gleich ' num2str(xR) ' und ' num2str(xL)])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement