Write a Regula Falsi program in Matlab to find the angle of the projectile motio
ID: 3892525 • Letter: W
Question
Write a Regula Falsi program in Matlab to find the angle of the projectile motion equation. Let the program start at [0,1.6]
Explanation / Answer
(False Position or Regula Falsi Method). To approxi-
mate a root of the equation f(x) = 0 in the interval [a, b]. Proceed with
the method only if f(x) is continuous and f(a) and f(b) have opposite signs.
Put the values of a = 0 and b = 1.6
a as left and b as right end points
function [c, err, yc] = regula (f, a, b, delta, epsilon, maxl)
%Input - f is the function input as a string ’f’
% - a and b are the left and right end points
% - delta is the tolerance for the zero
% - epsilon is the tolerance for the value of f at the zero
% - max1 is the maximum number of iterations
%Output - c is the zero
% - yc = f(c)
% - err is the error estimate for c
ya=feva1(f,a);
yb=feva1(f,a);
if ya*yb>0
disp (’Note: f(a)*f(b)>0’),
break,
end
for k=1:max1
dx=yb*(b-a)/(yb-ba);
c=b-dx;
ac=c-a;
yc=feval(f,c);
if yc==0, break;
elseif yb*yc>0
b=c;
yb=yc;
end
dx=min (abs (dx), ac);
if abs (dx)<delta, break, end
if abs (yc)<epsilon, break, end
end
c;
err=abs (b-a)/2;
yc=feval(f,c);
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.