Matlab – calculate geometric properties, engineering homework help
Attached is the code I have already created..
I need help figuring out how to plot each option, and I need to add another option to calculate the geometric properties of an arbitrary shape (something not considered to be a rectangle, circle, triangle, etc.)(something irregular).
% Option #4: Calculate geometric properties of arbitrary 2D shapes
_x000D_% Area, Moments of inertia
_x000D_ _x000D_while 1
_x000D_ _x000D_fprintf('nttMenun');
_x000D_ _x000D_fprintf('1. Rectangle or parallelogramn');
_x000D_ _x000D_fprintf('2. Hollow Rectangular Sectionn');
_x000D_ _x000D_fprintf('3. Circular Sectionn');
_x000D_ _x000D_fprintf('4. Hollow Circular Sectionn');
_x000D_ _x000D_fprintf('5. Triangle n');
_x000D_ _x000D_fprintf('6. I-beam n')
_x000D_ _x000D_fprintf('7. Exit n');
_x000D_ _x000D_x = input('Enter your option: ');
_x000D_ _x000D_switch(x)
_x000D_ _x000D_case 1
_x000D_ _x000D_fprintf('nRectangle or paralleogramn');
_x000D_ _x000D_b = input('Enter the width: ');
_x000D_ _x000D_d = input('Enter the height: ');
_x000D_ _x000D_Ixx = (b*d^3)/12;
_x000D_ _x000D_Iyy = (d*b^3)/12;
_x000D_ _x000D_A = b*d;
_x000D_ _x000D_fprintf('Area = %.2fn',A);
_x000D_ _x000D_fprintf('Moment of Inertia Ixx = %.2fn',Ixx);
_x000D_ _x000D_fprintf('Moment of Inertia Iyy = %.2fn',Iyy);
_x000D_ _x000D__x000D_
case 2
_x000D_ _x000D_fprintf('nHollow Rectangular Sectionn');
_x000D_ _x000D_b = input('Enter the outside width: ');
_x000D_ _x000D_d = input('Enter the outside height: ');
_x000D_ _x000D_b1 = input('Enter the inner width: ');
_x000D_ _x000D_d1 = input('Enter the inner height: ');
_x000D_ _x000D_Ixx = (b*d^3)/12-(b1*d1^3)/12;
_x000D_ _x000D_Iyy = (d*b^3)/12-(d1*b1^3)/12;
_x000D_ _x000D_A = b*d-b1*d1;
_x000D_ _x000D_fprintf('Area = %.2fn',A);
_x000D_ _x000D_fprintf('Moment of Inertia Ixx = %.2fn',Ixx);
_x000D_ _x000D_fprintf('Moment of Inertia Iyy = %.2fn',Iyy);
_x000D_ _x000D_case 3
_x000D_ _x000D_fprintf('nCircular Sectionn');
_x000D_ _x000D_d = input('Enter the diameter: ');
_x000D_ _x000D_Ixx = (pi*d^4)/64;
_x000D_ _x000D_Iyy = Ixx;
_x000D_ _x000D_A = (pi*(d/2)^2);
_x000D_ _x000D_fprintf('Area = %.2fn',A);
_x000D_ _x000D_fprintf('Moment of Inertia Ixx = %.2fn',Ixx);
_x000D_ _x000D_fprintf('Moment of Inertia Iyy = %.2fn',Iyy);
_x000D_ _x000D_case 4
_x000D_ _x000D_fprintf('nHollow circular sectionn');
_x000D_ _x000D_d = input('Enter the inner diameter: ');
_x000D_ _x000D_D = input('Enter the outside diameter: ');
_x000D_ _x000D_Ixx = (pi/64)*(D^4-d^4);
_x000D_ _x000D_Iyy = Ixx;
_x000D_ _x000D_A = pi*((D/2)^2)-((d/2)^2);
_x000D_ _x000D_fprintf('Area = %.2fn',A);
_x000D_ _x000D_fprintf('Moment of Inertia Ixx = %.2fn',Ixx);
_x000D_ _x000D_fprintf('Moment of Inertia Iyy = %.2fn',Iyy);
_x000D_ _x000D_case 5
_x000D_ _x000D_fprintf('nTrianglen');
_x000D_ _x000D_b = input('Enter the width: ');
_x000D_ _x000D_h = input('Enter the height: ');
_x000D_ _x000D_Ig = (b*h^3)/36;
_x000D_ _x000D_A = (b*h)/2;
_x000D_ _x000D_fprintf('Area = %.2fn',A);
_x000D_ _x000D_fprintf('Moment of Inertia Ig = %.2fn',Ig);
_x000D_ _x000D_case 6
_x000D_ _x000D_fprintf('nI-Sectionn');
_x000D_ _x000D_d = input('Enter the height: ');
_x000D_ _x000D_d1 = input('Enter the inner height (d1): ');
_x000D_ _x000D_b = input('Enter the width: ');
_x000D_ _x000D_b1 = input('Enter the inner width (b1): ');
_x000D_ _x000D_Ixx = (b*d^3)/12-(b1*d1^3)/12;
_x000D_ _x000D_Iyy = (d*b^3)/12-(d1*b1^3)/12;
_x000D_ _x000D_A = b*(d-d1)+(d1*(b-b1));
_x000D_ _x000D_fprintf('Area = %.2fn',A);
_x000D_ _x000D_fprintf('Moment of Inertia Ixx = %.2fn',Ixx);
_x000D_ _x000D_fprintf('Moment of Inertia Iyy = %.2fn',Iyy);
_x000D_ _x000D__x000D_ _x000D_
case 7
_x000D_ _x000D_break;
_x000D_ _x000D_otherwise
_x000D_ _x000D_fprintf('Invalid optionn' );
_x000D_ _x000D_end
_x000D_ _x000D_end