I have to write a program which will calculate using false position method the maximum of a given equation. And at the end I need to return the root and a value of the function at that point. I am not getting the answer can anyone help? )

7 visualizaciones (últimos 30 días)
%The root should be equal to 225, at least thats what i got when i did same question using bisection method
function [ xr ] = false_position( f,g, xl, xu )
w=1.75;
E=5*10.^5;
I=3*10.^5;
L=450;
g=@(x)(w/(120*E*I*L))*(-x.^5+2*L.^2*x.^3-L.^4*x);%orignal
f=@(x)(w/(120*E*I*L))*(-5*x.^4+6*L.^2*x.^2-L.^4);%derivative
xl=0;
xu=L;
if f(xl)*f(xu)>0
disp('error wrong end points')
else
xr=(xl*f(xu)-xu*f(xl))/(f(xu)-f(xl));
error=abs(f(xr));
while error>1e-4;
if f(xr)>0
xu=xr;
else
xl=xr;
end
xr=(xl*f(xu)-xu*f(xl))/(f(xu)-f(xl));
error=abs(f(xr));
end
fprintf('The point of maximum deflection is: %f\n', xr);
fprintf('The value of maximum deflection is: %f\n',g(xr));
end*
  2 comentarios
James Tursa
James Tursa el 29 de Mzo. de 2018
Do not post screen shots of code. We can't copy & paste screen shots into MATLAB to run. Please remove your screen shot and replace it with text of your code (and use the { } Code button to format your code as well).

Iniciar sesión para comentar.

Respuestas (1)

Daniel Stankowski
Daniel Stankowski el 1 de Abr. de 2018
could anyone help out?

Categorías

Más información sobre Startup and Shutdown en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by