A resistance load is applied to the ankle with the leg posit
A resistance load is applied to the ankle with the leg positioned as shown below. The forces on the leg when the knee is in full extension can be represented with the following linear system of equations: R_x - F_PL cos(theta) = 0 R_y + F_PL sin(theta) - W_L - W_R = 0 0.06 F_PL - 0.32W_L - 0.45W_R = 0 where theta is the angle between the muscle and the leg (20 degrees) W_L is the weight of the leg (57 N) W_R is the resistance load (N) R_x and R_y are the reaction loads at the knee joint (N) F_PL is the force in the patellar ligament (N) Write a MATLAB script or function (your choice) to accomplish the following tasks: Starting at an initial resistance load W_R of 50 N and increasing the resistance load W_R by 5 N, solve the matrix form of the linear system of equations for unknown loads. R_x, R_y, and F_PL to satisfy the linear system of equations. Repeat the load calculations until the force in the patellar ligament F_PL is above than 2000 N.? After the desired force is achieved, output the final force in the patellar ligament F_PL, the final resistance load W_R, a message describing the order of the unknown quantities, and the unknown quantities to the screen using the appropriate output mechanism.
Solution
function F=mcs(X,y,A,method,N,ratio,OPT) %+++ Monte-Carlo Sampling method for outlier detection. %+++ X: sample matrix: M x P. %+++ y: Response variable: p-dimensional. %+++ A: number of PLS components. %+++ N: Number of Monte Carlo Sampling, default value:2500. %+++ ratio: The ratio of samples randomly selected to build a PLS model, default 0.8. %+++ OPT: 0 Model is not optimized in each MCS. % 1 Model is optimized in each MCS. %+++ Ref: Q.S. Xu, Y.Z. Liang, 2001.Chemo Lab,1-11. %+++ Edited by H.D. Li,Feb.7, 2009. %+++ Tutor: Yizeng Liang, yizeng_liang@263.net. %+++ E-mail: lhdcsu@gmail.com. %+++ Default parametrical settings. if nargin<7;OPT=0;end; if nargin<6;ratio=0.75;end; if nargin<5;N=1000;end; if nargin<4;method=\'center\';end; if nargin<3;A=3;end; [Mx,Nx]=size(X); % Data size. A=min([size(X) A]); % Latent Variable correction. nc=floor(Mx*ratio); % Number of calibration samples. nv=Mx-nc; % Number of test samples. Resi=nan(N,Mx); % Initialize the error matrix which records the prediction errors of each sample in each iteration. %+++ Main loop for calculate the prediction errors for each sample. for i=1:N index=randperm(Mx); calk=index(1:nc);testk=index(nc+1:Mx); Xcal=X(calk,:);ycal=y(calk); Xtest=X(testk,:);ytest=y(testk); %+++ Randomly select calibration and test set. % data pretreatment [Xs,xpara1,xpara2]=pretreat(Xcal,method); [ys,ypara1,ypara2]=pretreat(ycal,method);