Develop the nonlinear system of equations for the position o

Develop the nonlinear system of equations for the position of the bars using rigid body kinematics. The unknowns are ?2 and x; you may assume ?1, L1, L2, and h are given.

Write a MATLAB function that solves a nonlinear system of equations using Newton’s method. The function should take function handles to the system of equations, f and to the Jacobian, J; it should also take the initial guess x0, the tolerance ?tol, and the maximum number of iterations.

For the remainder of the assignment, take L1 = 0.5 m, L2 = 1.0 m, h = 0 m. Now, write a MATLAB script that does the following:

(a) Load the time series of ?1(t) given in lab10 theta1.dat (use the command load(’lab10 theta1.dat’,’-mat’)). The data (t theta) is a two-dimensional ar- ray containing the value of time t in the first row and the corresponding values of ?1 in the second row.

(b) For each value of ?1(t), use your Newton solver to solve the nonlinear system of equations for ?2 and x.

(c) Plot?1 vs. t,?2 vs. t,andxvs. t.

L2 L

Solution

function x = NewtonMethod(funcF,JacobianF,n)

F = funcF;

J = JacobianF;

x = zeros(n,1); % set initial to (0,...,0)

Iter = 1;

MaxIter = 100;

TOL = 1e-5;

while Iter < MaxIter disp([’Iter = ’ num2str(Iter)]);

y = J(x)\\(-F(x));

x = x+y;

if norm(y,2) < TOL break; end

disp ([\'x= \' num2str(X\')];

end

if iter >= MaxIter

disp(’Maximum number of iteration exceeded!’); end

end

% function F

function y = F(x)

x1 = x(1);

x2 = x(2);

y = zeros(2,1);

y(1) = x1^2-x2^2+2*x2; % f1(x1,x2)

y(2) = 2*x1+x2^2-6; % f2(x1,x2);

end

% Jacobian matrix of F

function A = J(x) x1 = x(1);

x2 = x(2);

A = zeros(2,2);

A(1,1) = 2*x1; % df1x1

A(1,2) = -2*x2+2; % df1x2

A(2,1) = 2; % df2x1

A(2,2) = 2*x2; % df2x2;

end

function newtonSol

x = NewtonMethod(@F,@J,2);

end

Develop the nonlinear system of equations for the position of the bars using rigid body kinematics. The unknowns are ?2 and x; you may assume ?1, L1, L2, and h
Develop the nonlinear system of equations for the position of the bars using rigid body kinematics. The unknowns are ?2 and x; you may assume ?1, L1, L2, and h

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site