Question

In: Advanced Math

Use MATLAB to create a script which solves for problem 5.9 in the book (5.11 in...

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!

Solutions

Expert Solution

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.


Related Solutions

Use Matlab and write entier script Problem 2. Generate the estimate (linear estimate) for y_est, and...
Use Matlab and write entier script Problem 2. Generate the estimate (linear estimate) for y_est, and plot(x , y_est). Use “hold on” and plot(x,y) and plot(x,y_est), so that you can see the result of the line and how it fits the data.   Does it look like it did a pretty good job? An estimate of the “residual error” is the sum of the squares of the difference between y and y_est. This is often denoted as r2. r2 = sum(...
(MATLAB) Write a script that would create a 3x5 matrix of random integers and write this...
(MATLAB) Write a script that would create a 3x5 matrix of random integers and write this new matrix to a file called “Assignment3_Question5.dat”.
Create a MATLAB script file to determine the given function is continuous or discontinuous at given...
Create a MATLAB script file to determine the given function is continuous or discontinuous at given interval (points).
Use Matlab and write entier script Problem 1. Using the information above, find y(n) for all...
Use Matlab and write entier script Problem 1. Using the information above, find y(n) for all n between 1:N. y(tn)=mx(tn)+b+r(tn) y=mx+b Plot the points on a graph, without connecting them with a line.   Use a command like: plot( x, y, ‘.r’ ) Now we want to find the “best fit” solution.   As was mentioned before, this was defined in the prior exercise. (You may wish to read this to understand how the algorithm works.)   Use the MATLAB code below. You...
This is a Matlab Exercise problem. Please create the Matlab code and figure for the following...
This is a Matlab Exercise problem. Please create the Matlab code and figure for the following problem using problem specifications: Plot x vs y when y=sin(x), y=cos(x), y=sin (2*x), and y=2*sin(x) when x = 1:0.1:10. Use 2 by 2 subplot, sin(x) is in location 1, cos(x) is in location 2, sin(2*x) is in location 3 and 2*sin(x) is in location 4. The plot should have: (1) x label = ‘x value’, y label = ‘y value’, legend ‘y=sin(x)’,’ y=cos(x)’,’ y=sin...
creat a Matlab simulation the solves the 2D heat equation.
creat a Matlab simulation the solves the 2D heat equation.
Matlab script that uses loops to create a multiplication table (matrix) where the user enters 'n'...
Matlab script that uses loops to create a multiplication table (matrix) where the user enters 'n' (nxn chart).
Using MATLAB or Octave, use documenting code to Write a script that prompts the user for...
Using MATLAB or Octave, use documenting code to Write a script that prompts the user for a minimum and maximum real number, then generates and prints a random number in the requested range. The script should then do the same for an integer range. Sample output: Enter a minimum real value: 0.5 Enter a maximum real value: 30 A random number in the range ( 0.5000, 30.0000 ) is 1.7851 Enter a minimum integer value: -10 Enter a maximum integer...
Use CYGWIN TERMINAL to create this script. COPY AND PASTE the screenshot. Script 1: 1.   Perform...
Use CYGWIN TERMINAL to create this script. COPY AND PASTE the screenshot. Script 1: 1.   Perform a ls -al on the files within the user's home directory and save it to a file called ls.dat within your ~ directory 2.   Save the tree information for the /home directory in a file called tree.dat within your ~directory 3.   Create a new directory in your home directory called "backups" 4.   Move the files you just created to the new directory 5.   Rename...
Fluid Mechanics Friction Problem: Write one MATLAB m-file that solves the Type I and II problems...
Fluid Mechanics Friction Problem: Write one MATLAB m-file that solves the Type I and II problems presented in class based on the file posted for the Type III problem (use Colebrook to estimate f). Type I: Solve hL for v=0.74x10-5ft^2/s, D=3 in, L=1000 ft, e=0.006 in, and Re=80000. f=0.0258 from Moody Chart. Type II: Solve Q for v=10^-6 m^2/s, D=0.2 m, L=500 m, e=0.046 mm, and hL=30m. Use “rough” Colebrook to generate an estimate for f.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT