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

Using Matlab create an m. file that solves the following problem. Ramanujan's taxi. S. Ramanujan was...
Using Matlab create an m. file that solves the following problem. Ramanujan's taxi. S. Ramanujan was an Indian mathematician who became famous for his intuition for numbers. When the English mathematician G. H. Hardy came to visit him in the hospital one day, Hardy remarked that the number of his taxi was 1729, a rather dull number. To which Ramanujan replied, "No, Hardy! No, Hardy! It is a very interesting number. It is the smallest number expressible as the sum...
• In this script, write MATLAB code to create an array A of size 100 ×...
• In this script, write MATLAB code to create an array A of size 100 × 3. The first column should contain random numbers between 0 and 10. The second column should also contain random numbers between 0 and 10. The third column should contain random integers between 20 and 50. The first two columns represent the x and y coordinates of a map, respectively. The third column represents the height of buildings. For example, if the first row of...
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 Code only Please create a MATLAB script that is a TIC-TAC-TOE game. Please keep it...
**MATLAB Code only Please create a MATLAB script that is a TIC-TAC-TOE game. Please keep it simple, but there is no other rules. Thank you.
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...
(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).
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT