Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function [outputArg1] = nullstelle(p,xL,xR)
- %UNTITLED2 Summary of this function goes here
- % Detailed explanation goes here
- h = abs (xR - xL);
- if polyval(p,xL)*polyval(p,xR) > 0
- 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.'])
- elseif polyval(p,xL)*polyval(p,xR) < 0
- while h > 10^(-15)
- if polyval(p,xL)*polyval(p,0.5*(xL+xR)) < 0
- xR = 0.5*(xR+xL);
- h = abs (xR - xL);
- elseif polyval(p,xL)*polyval(p,0.5*(xL+xR)) > 0
- xL = 0.5*(xR+xL);
- h = abs (xR - xL);
- elseif polyval(p,xL)*polyval(p,0.5*(xL+xR)) == 0
- xL = 0.5*(xR+xL);
- xR = xL;
- h = 0;
- end
- end
- disp(['Es gibt mindestens eine Nullstelle gleich : ' num2str(xL)]);
- elseif polyval(p,xL)*polyval(p,xR) == 0
- if polyval(p,xL) == 0
- disp(['Es gibt eine Nullstelle gleich ' num2str(xL)])
- elseif polyval(p,xR) == 0
- disp(['Es gibt eine Nullstelle gleich ' num2str(xR)])
- elseif polyval(p,xL) == 0 && polyval(p,xR) == 0
- disp(['Es gibt zwei Nullstellen gleich ' num2str(xR) ' und ' num2str(xL)])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement