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 is program Respond fast please a quiz Create a MATLAB script. Using nested for loops,...
MATLAB is program Respond fast please a quiz Create a MATLAB script. Using nested for loops, evaluate the multivariable function: z = sin ⁡ ( x ) cos ⁡ ( y ) for x between -4 and 4 in steps of 1 y between -2 and 2 in steps of 1 Display the matrix z Cut and paste the following into a word doc and submit to this question. Your script code Your input Your output
(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...
c programing language This assignment, which introduces the use of loops, solves the following problem: given...
c programing language This assignment, which introduces the use of loops, solves the following problem: given a starting location in a city, how long does it take a “drunken sailor” who randomly chooses his direction at each intersection to reach the city’s border? You will read input values to set up the problem parameters, run several trials to determine an average number of steps for the sailor to reach the border, and output the results. This problem is an example...
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...
In MATLAB: (a) Insert a comment in your script that says Problem 1: (b) Below this...
In MATLAB: (a) Insert a comment in your script that says Problem 1: (b) Below this comment, generate a vector of values called x that starts at −10, ends at 8, and has a step size of 0.1 between points. (c) Define the function f(x) = (x − 6)(x 2 − 1)(x + 8) in your script, then plot f(x) against x. (d) Plot the x- and y-axes on the plot in part (c). Mark each of the x-intercepts on...
MATLAB: Create your own problem in words that use loop and selection statements in the same...
MATLAB: Create your own problem in words that use loop and selection statements in the same problem. Create a problem that has a somewhat practical, real-life application like entering your PIN code at an ATM, and then after 4 incorrect tries, you are locked out of the ATM. Or create a problem based perhaps upon a physics or chemistry lab.   The problem should require the use of a WHILE loop, a FOR loop and a minimum of 3 selection statements...
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT