In: Mechanical Engineering
Using MATLAB create a code to locate the centriod and moments of interia about the centriod of a stiffened rectangular plate with or without cut outs,
This program gives centroid and moment of inertia as output for coordinates of rectangle as input
Save the code as "Rect.m"
let x be x-coordinates of rectangle and y be y-coordinate of
rectangle
call the program as "Rect(x,y)"
example:
x = [ 2.000 0.500 4.830 6.330 ]';
y = [ 4.000 6.598 9.098 6.500 ]';
Rect(x,y)
OUTPUT:
x_cen=3.415, y_cen=6.549
Ixx=659.561, Iyy=201.173, Ixy=344.117
__________________________________________________________________
function [ Centroid, M_Inertia ] = Rect( x, y )
if ~isequal( size(x), size(y) )
error( 'X and Y must be the same size');
end
xm = mean(x);
ym = mean(y);
x = x - xm;
y = y - ym;
xp = x( [2:end 1] );
yp = y( [2:end 1] );
a = x.*yp - xp.*y;
A = sum( a ) /2;
xc = sum( (x+xp).*a ) /6/A;
yc = sum( (y+yp).*a ) /6/A;
Ixx = sum( (y.*y +y.*yp + yp.*yp).*a ) /12;
Iyy = sum( (x.*x +x.*xp + xp.*xp).*a ) /12;
Ixy = sum( (x.*yp +2*x.*y +2*xp.*yp + xp.*y).*a ) /24;
dx = xp - x;
dy = yp - y;
P = sum( sqrt( dx.*dx +dy.*dy ) );
if A < 0,
A = -A;
Ixx = -Ixx;
Iyy = -Iyy;
Ixy = -Ixy;
end
Iuu = Ixx - A*yc*yc;
Ivv = Iyy - A*xc*xc;
Iuv = Ixy - A*xc*yc;
J = Iuu + Ivv;
x_cen = xc + xm;
y_cen = yc + ym;
Ixx = Iuu + A*y_cen*y_cen;
Iyy = Ivv + A*x_cen*x_cen;
Ixy = Iuv + A*x_cen*y_cen;
I = [ Iuu -Iuv ;
-Iuv Ivv ];
[ eig_vec, eig_val ] = eig(I);
I1 = eig_val(1,1);
I2 = eig_val(2,2);
ang1 = atan2( eig_vec(2,1), eig_vec(1,1) );
ang2 = atan2( eig_vec(2,2), eig_vec(1,2) );
Centroid= [ A x_cen y_cen P ];
M_Inertia = [ Ixx Iyy Ixy };
end
________________________________