Write a MATLAB program to find the tensile strength sigmat a

Write a MATLAB program to find the tensile strength (sigma_t) at t_l = 30 by fitting a function to Using linear least-squares regression (Regress.m). The input parameters are t, sigma, and t_l, and the output parameters are a_1, a_0, S_r, R^2, and sigma_t. The program SHOULD be written based on the algorithm in Figure 17.6 of the textbook: Using Newton\'s interpolating polynomial (NewtInt.m). The input parameters are t, sigma, and t_l and the output parameter is sigma_t. The program SHOULD be written based on the algorithm in Figure 18.7 of the textbook. Using Lagrange interpolation (Lagrng.m). The input parameters are t, sigma, and t_l and the output parameter is sigma_t. The program SHOULD be written based on the algorithm in Figure 18.11 of the textbook. Using MATLAB command polyfit.

Solution

MATLAB CODE:

clear all

clc

%Data

t=[10 15 20 25 40 50 55 60 75];

s=[5 20 18 40 33 54 70 60 78];

ti=30;

%Linear least-squares regression

R=Regress(t,s,ti);

%Newton\'s interpolating polynomial

N=NewtInt(t,s,ti);

%Lagrange interpolation

%L=Lagrng(t,s,ti); %%%%%%%%%%%%%%% THIS ISN\'T PROGRAMED YET, CONSULT THE

%%%%%%%%%%%%%%% REFERENCED TEXTBOOK BY THE PROBLEM

%MATLAB command \"polyfit\"

P=polyfit(t,s,1);

si=P(1)*ti+P(2);

M=[P si]

function R=Regress(x,y,xi)

n=length(x);

for i=1:n

xy(i)=x(i)*y(i);

x2(i)=x(i)^2;

y2(i)=y(i)^2;

end

Sx=sum(x);

Sy=sum(y);

Sxy=sum(xy);

Sx2=sum(x2);

Sy2=sum(y2);

a1=(n*Sxy-Sx*Sy)/(n*Sx2-Sx^2);

Px=Sx/n;

Py=Sy/n;

ao=Py-a1*Px;

for i=1:n

S(i)=(y(i)-(a1*x(i)+ao))^2;

end

Sr=sum(S);

R2=0;%%%%%%%%%%%%%%% FIND THE EQUATION FOR SQUARE R AN PROGRAM IT HERE

si=a1*xi+ao;

R=[a1 ao Sr R2 si]

end

function N=NewtInt(x,y,xi)

n=length(y);

k=1;

a(1)=y(1);

Y=y;

while n~=1

for i=1:n-1

f(i)=(y(i+1)-y(i))/(x(i+k)-x(i));

end

y=f;

n=n-1;

k=k+1;

N=1;

a(k)=y(1);

%%%%%%%%%%% THE COMPONENTS OF \"a\" ARE THE COEFFICIENTS a0, a1,...,an

%%%%%%%%%%% NOW USE THIS COEFFICIENTES TO WRITE THE EQUATION AND

%%%%%%%%%%% REPLACE x=xi TO KNOW si

end

 Write a MATLAB program to find the tensile strength (sigma_t) at t_l = 30 by fitting a function to Using linear least-squares regression (Regress.m). The input
 Write a MATLAB program to find the tensile strength (sigma_t) at t_l = 30 by fitting a function to Using linear least-squares regression (Regress.m). The input

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site