This is what i got so far and I know this data is correct for my assignment.Now
ID: 3626802 • Letter: T
Question
This is what i got so far and I know this data is correct for my assignment.Now i need to find the roots of the fuction and use bi-section method.
function y=falling_jumper(x)
g=9.8;
c=14.
v=35.
t=7.
x=1:100
y=(g*x./c).*(1-exp(-(c*t)./x))-v;
plot(x,y)
Explanation / Answer
This is a nice tutorial about the Bisection method http://www.cs.utah.edu/~zachary/isp/applets/Root/Bisection.html Some information about the algorithm http://en.wikipedia.org/wiki/Root-finding_algorithm The code in Mathlab Matlab Scripts for root finding using bisection ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ function xb=bisect(a,b,tol) % Matlab function bisect.m % Solves f(x) = 0 using the bisection method % % Inputs: % a = left endpoint of interval % b = right endpoint of interval % tol = tolerance for stopping bisection method % % Required m-file: % f.m is m-file for function f(x) % Outputs: % Root by bisection % % it=0; % set iteration count to zero fa=f(a); fb=f(b); % % check bracketing % if sign(fa)==sign(fb), error('Root not in bracket'); end % % begin while loop % while (b-a)>tol it=it+1; c=a+0.5*(b-a); fc=f(c); if sign(fa)~=sign(fc); % root lies in [a,c] b=c; fb=fc; else % root lies in [c,b] a=c; fa=fc; end % print progress xb=0.5*(a+b); err=0.5*abs(b-a);fprintf(' n = %i Solution = %15.10e error = %15.10e ',it,xb, err); pause; % The pause command causes the execution of this routine to % be paused at the end of each iteration. Press any key % on the keyboard to continue. end % print results format long e fprintf(' Computed Solution = %e ',xb); fprintf(' Iteration count = %i ',it); *********************************************************** function y=f(beta) % Specify parameters a1=7; a2=6; a3=5; a4=4; c=(a1^2+a2^2-a3^2+a4^2)/(2*a2*a4); alpha=45; % degrees alpha=alpha*pi/180; % radians y=(a1/a2)*cos(beta) - (a1/a4)*cos(alpha)-cos(beta-alpha)+c; *********************************************************** Matlab Scripts for root finding using Newton ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ function [r,k] = Newton(fun,x0,tol) % % Input: fun = (string) name of mfile that returns f(x) and f'(x) % x0 = initial guess % % Output: r = the root % k = number of iterations used x = x0; % initial guess k = 0; % initialize iteration counter maxit=50; % max iterations allowed while kRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.