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*
  댓글 수: 2
James Tursa
James Tursa 2018년 3월 29일
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).

댓글을 달려면 로그인하십시오.

답변 (1개)

Daniel Stankowski
Daniel Stankowski 2018년 4월 1일
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