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? )

6 次查看(过去 30 天)
%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*

回答(1 个)

Daniel Stankowski
could anyone help out?

类别

Help CenterFile Exchange 中查找有关 Startup and Shutdown 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by