Question

Write The MATLAB SCRIPT for: An open-top box is constructed from a rectangular piece of sheet metal measuring 10 by 16 i...

Write The MATLAB SCRIPT for:

An open-top box is constructed from a rectangular piece of sheet metal measuring 10 by 16 inches. Square of what size (accurate to 10-9 inch) should be cut from the corners if the volume of the box is to be 100 cubic inches?
Notes: to roughly estimate the locations of the roots of the equation and then approximate the roots to this equation using Newton Iteration method.

Please don't give me the Matlab Commands for this. I need "Matlab Script" as its solution.

0 0
Add a comment Improve this question Transcribed image text
Answer #1


Length ‘1-4 ka, metal O inches s neto om d LAMatlab code for finding root using Newton method clear all close all %Function for which root have to find fun-e(x) x.*(10-2.ffx) vs x plot 50 -50 100 0 0.5 1.5 2.5 3.5 Published with MATLAB R2018a


%%Matlab code for finding root using Newton method
clear all
close all


%Function for which root have to find
fun=@(x) x.*(10-2.*x).*(16-2.*x)-100;

%plotting of the function
xx=linspace(0,4,1001);
yy=fun(xx);
plot(xx,yy)
xlabel('x')
ylabel('y')
title('f(x) vs x plot')

%displaying the function
fprintf('For the function\n')
disp(fun)

[root]=newton_method(fun,0,1000);

fprintf('Value of x =%f.\n',root)

%Matlab function for Newton Method
function [root]=newton_method(fun,x0,maxit)
syms x
g1(x) =diff(fun,x);   %1st Derivative of this function
xx=x0;            %initial guess]
%Loop for all intial guesses
    n=eps; %error limit for close itteration
    for i=1:maxit
        x2=double(xx-(fun(xx)./g1(xx))); %Newton Raphson Formula
        cc=abs(fun(x2));                 %Error
        err(i)=cc;
        xx=x2;
        if cc<=n
            break
        end
      
    end
    root=xx;
end

%%%%%%%%%%%%%%%% End of Code %%%%%%%%%%%%%%%

Add a comment
Know the answer?
Add Answer to:
Write The MATLAB SCRIPT for: An open-top box is constructed from a rectangular piece of sheet metal measuring 10 by 16 i...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT