In: Advanced Math
Use MATLAB to create a script which solves for problem 5.9 in the book (5.11 in the 4th edition). Given are the equations for the moment, as a function of x, starting from the leftmost side of the beam with x=0 and ending at the other end of the beam with x=12. This piecewise function together makes up the moment equation for the beam given. 0 ≤ ? ≤ 3 ?(?) = 265? − 5.56?3 , 3 < ? ≤ 6 ?(?) = −50?2 + 415? − 150, 6 < ? ≤ 10 ?(?) = −185? + 1650, 10 < ? ≤ 12 ?(?) = 100? − 1200 Use if-else statements to determine the f(x) value for each value of x (lower bound, upper bound, and the guess for the root) to use in the bisection method. Also, use a while loop to iterate until the approximate relative error is below the stopping criterion, es=0.05%. Finally, plot piecewise function and verify that the root found is at or near the point on the beam in which the moment is zero. Create appropriate labels (xaxis, y-axis, and title). Here's what should happen when the script is run:
>> Lab3Roots
>> xr =
8.918907165527344
PLEASE SHOW HOW TO TYPE THE SCRIPT! THANKS!
Hey,
Note: Brother in case of any queries, just comment in box I would be very happy to assist all your queries
function Lab3Roots()
e=0.05e-2;
a=1;
b=11;
iter = 0;
if func1(a)*func1(b)>=0
disp('No Root')
else
prev = (a+b)/2;
p=a;
while (abs(p-prev)/p>e)
prev=p;
iter =iter+ 1;
p = (a+b)/2;
if f(p) == 0
break;
end
if func1(a)*func1(p)<0
b = p;
else
a = p;
end
if(iter==100)
disp('the required
accuracy is not reached in 50 iterations');
end
end
end
xr=p
X=0:0.01:12;
for i=1:length(X)
Mo(i)=func1(X(i));
end
plot(X,Mo,xr,func1(xr),'*r');
grid on;
function M=func1(x)
if(x>=0&&x<=3)
M=265*x-5.56*x^2;
elseif(x<=6)
M=-50*x^2+415*x-150;
elseif(x<=10)
M=-185*x+1650;
else
M=100*x-1200;
end
end
end
Kindly revert for any queries
Thanks.