Академический Документы
Профессиональный Документы
Культура Документы
1
Ex. No. : 01 STRESS ANALYSIS OF A PLATE WITH A CIRCULAR HOLE
Date :
AIM:
To determine the displacement and bending stress of a given plate with a circular hole using Finite
Element Analysis based ANSYS structure and view the displacement and bending stress plots.
PROCEDURE:
1. Enter the title of the analysis
Utility Menu > File > Select Change Title> Enter New Title > Stress Analysis of a Plate with
Hole > Ok
2
ANSYS Main Menu > preferences > turn on Structural > Ok
Options > pull down K3 plane stress and select plane strs w/thk.> Ok > close
3
3. Define Real constants
4
4. Define Material Properties
Preprocessor > Material Props > Material Models > Structural > Linear > Elastic > Isotropic > Enter EX
= 200000 and Enter PRXY = 0.3 > Ok > Close
5. Modeling
a. Create the main rectangular shape
Preprocessor > Modeling > Create > Areas > Rectangle > By 2 Corners > WP X=0, WP Y=0, Width =
200 and Height = 100.
5
b. Create the circle
Preprocessor > Modeling > Create > Areas > Circle > Solid Circle > WP X= 100, WP Y=50 and
Radius = 20
6
c. Numbering Areas
Utility Menu >plot controls > Numbering> pick Areas
d.Subtraction
Now we want to subtract the circle (2) from the rectangle (1). Prior to this operation, your image
should resemble the following:
Modeling > Operate > Booleans > Subtract > Areas > Enter 1 > Ok > Enter 2 > Ok
7
6. Mesh Size
Preprocessor > Meshing > Size Cntrls > Manual Size > Areas > All Areas
2. Apply Constraints
As shown previously, the left end of the plate is fixed.
Preprocessor > Define Loads > Apply > Structural > Displacement > On Lines > Using Mouse Select
the left end vertical line of the plate > click on 'Apply' in the window > Ok.
8
o Fill in the window as shown below.
This location is fixed which means that all DOF's are constrained. Therefore, select 'All DOF' by
clicking on it and enter '0' in the Value field as shown above.
You will see some blue triangles in the graphics window indicating the displacement constraints.
3. Apply Loads
o As shown in the diagram, there is a load of 20N/mm distributed on the right hand side of the
plate. Calculate the pressure on the plate end by dividing the distributed load by the thickness of
the plate (1 N/mm2).
Solution > Define Loads > Apply > Structural > Pressure > On Lines > Using Mouse Select the right
end vertical line of the plate > click on 'Apply' in the window
9
o Fill in the "Apply PRES on lines" window as shown below > Ok.
The pressure is uniform along the surface of the plate; therefore the last field is left blank.
The pressure is acting away from the surface of the plate, and is therefore defined as a
negative pressure.
o The applied loads and constraints should now appear as shown below.
10
4. Solving the System
Solution > Solve > Current LS > Ok.
5. Deformation
General Postproc > Plot Results > Deformed Shape > select Def + undeformd > Ok
11
6. Deflection
General Postproc > Plot Results > Contour plot > Nodal Solution > Nodal Solution > pick DOF solution
> select Displacement Vector Sum > In the bottom of the window select Deformed shape with
Undeformed model > Ok.
12
7. Stresses
General Postproc > Plot Results > Nodal Solution > pick Stress > select Von Mises Stress > In the
bottom of the window select Deformed shape with Undeformed model > Ok.
13
RESULT:
14
Ex. No. : 02 STRESS ANALYSIS OF SIMPLE BRACKET
Date :
AIM:
To determine the displacement and bending stress of a given simple bracket using Finite Element
Analysis bases ANSYS structure and view the displacement and bending stress plots.
PROCEDURE
Preprocessor > Real Constants > Add/Edit/Delete>Add>Ok>Enter THK = 20 >Ok > Close
5. Modeling
Preprocessor > Modeling > Create > Areas > Circle > Solid Circle> X=80,Y=50 and R=50 > Ok
c. Now create a second and third circle for the left hand side using the following dimensions:
Preprocessor > Modeling > Create > Areas > Circle > Solid Circle> X=0,Y=20 and R=20 > Ok
Preprocessor > Modeling > Create > Areas > Circle > Solid Circle> X=0,Y=80 and R=20 > Ok
d. Create a rectangle on the left hand end to fill the gap between the two small circles.
Preprocessor > Modeling > Create > Areas > Rectangle > By 2 Corners (X= -20, Y=20,
WIDTH= 20, HEIGHT =60)
f. We now want to add these five discrete areas together to form one area.
Modeling > Operate > Booleans > Add > Areas > Pick All
h. Numbering Areas
Ansys utility menu > Plot controls > Numbering > Areas Area numbers > Turn On
i. Subtract object ( Simple Bracket) from Three Holes
Preprocessor > Modeling > Operate > Booleans > Subtract > Areas > Enter ‘6’ (Simple Bracket)
> Apply>1,2,3 > OK
9. After meshing is done save the meshed model on a previous new folder
Ansys utility menu > plot controls > write metafile > invert
white/black
Solution Phase: Assigning Loads and Solving
10. Define Analysis Type
Solution' > 'New Analysis' and select 'Static'.
11. Apply Constraints
As illustrated, the plate is fixed at both of the smaller holes on the left hand side.
17
a. Solution > Define Loads > Apply > Structural > Displacement > On Nodes
In the dial box, select circle option. Now Pick center of circle and drag upto outer surface as
shown figure.> ok > select All DOF , Enter Displacement value = 0 and Repeat for Second small
circle.
18
14. Deflection
General Postproc > Plot Results > Contour Plot > Nodal Solu ... > DOF solution, > displacement
vector sum.> Ok
RESULT:
19
Ex. No. : 03. STRESS ANALYSIS OF SIMPLE RECTANGULAR L - BRACKET
Date:
AIM:
To determine the displacement and bending stress of a given L - bracket using Finite Element Analysis
bases ANSYS structure and view the displacement and bending stress plots.
PROCEDURE
Utility Menu > Change title > Stress Analysis of Rectangular L – Bracket > ok
20
Step 3: Define the element types
Main Menu > Preprocessor > Element Type > Add/Edit/Delete > Add > solid > 8 node Quad plane 82 >
ok
Options > choose plane stress with thickness > ok > close
Create rectangle
Main Menu> Preprocessor> Modeling> Create> Areas> Rectangle> By Dimensions > Enter the
Dimensions > ok
X1 0 4
X2 6 6
Y1 -1 -1
Y2 1 -3
Wp x 0 5
Wp y 0 -3
Radius 1 1
Add areas
21
Main Menu > Preprocessor > Modeling > Operate > Booleans > Add > Areas > Pick All
Create line fillet
Utility Menu > Plot Ctrls > Numbering > Turn on line numbering > ok > close
Main Menu > Preprocessor > Modeling > Create > Lines > Line Fillet > Pick the two lines > ok > Enter
the fillet radius 0.4 > ok > close
Main Menu > Preprocessor > Modeling > Create > Area > Arbitrary > By lines > Pick the Fillet line >
ok
Main Menu > Preprocessor > Modeling > Operate > Booleans > Add > Area > Pick All
Main Menu> Preprocessor> Modeling> Create> Areas> Circle> Solid Circle > Enter the Coordinates >
ok
Wp x 0 5
Wp y 0 -3
22
Step 7: Apply Boundary conditions and loads
Constraints
Main Menu > Solution > Define Loads > Apply > Structural > Displacement > On Lines > Pick the four
lines around left hand hole > ok > select All DOF > Enter the value 0 > ok > close
Pressure load
Main Menu > Solution > Define Loads > apply > Structural > Pressure > On Lines > Pick line defining
bottom left part of the circle > Apply > Enter 50 for VALUE > Enter 500 for optional value > Apply >
Pick line defining bottom right part of the circle > Apply > Enter 500 for VALUE > Enter 50 for
optional value > ok
Main Menu > Solution > Solve > Current LS > ok > close
Main Menu > General Postproc > Plot Results > Deformed Shape > choose Def + undeformed > ok
Main Menu > General Postproc > Plot Results > Contour Plot > Nodal Solution > select DOF Solution >
select Displacement vector sum > ok.
23
Von Mises Stresses
Main Menu > General Postproc > Plot Results > Nodal Solution > stress > select von Mises Stress
RESULT:
24
Ex. No. :04. STRESS ANALYSIS OF RECTANGULAR L - BRACKET
Date :
AIM:
To determine the displacement and bending stress of a given L - bracket using Finite Element Analysis
bases ANSYS structure and view the displacement and bending stress plots.
This is a simple, single load step, structural static analysis of the (corner angle) L-bracket shown below.
The upper left-hand pin hole is constrained (welded) around its entire circumference, and a tapered pressure
load is applied to the bottom of the lower right-hand pin hole. The objective of the problem is to demonstrate
the typical ANSYS analysis procedure.
PROCEDURE
Given
The bracket is made of A36 steel with a Young’s modulus of 30E6 psi and Poisson’s ratio of 0.27.
25
Approach and Assumptions
Assume plane stress for this analysis. Since the bracket is thin in the z direction (1/2 inch thickness) compared
to its x and y dimensions, and since the pressure load acts only in the x-y plane, this is a valid assumption.
Your approach is to use solid modeling to generate the 2-D model and automatically mesh it with nodes and
elements.
Build Geometry
1. Define rectangles.
2. Change plot controls and replot.
3. Change working plane to polar and create first circle.
4. Move working plane and create second circle.
5. Add areas.
6. Create line fillet.
7. Create fillet area.
8. Add areas together.
9. Create first pin hole.
10. Move working plane and create second pin hole.
11. Subtract pin holes from bracket.
12. Save the database as model.db.
Define Materials
13. Set Preferences.
14. Define Material Properties.
15. Define element types and options.
16. Define real constants.
Generate Mesh
17. Mesh the area.
Apply Loads
19. Apply displacement constraints.
20. Apply pressure load.
Obtain Solution
21. Solve.
Review Results
22. Enter the general postprocessor and read in the results.
23. Plot the deformed shape.
24. Plot the von Mises equivalent stress.
25. List the reaction solution.
Step 1: Define rectangles.
There are several ways to create the model geometry within ANSYS, some more convenient than others. The
first step is to recognize that you can construct the bracket easily with combinations of rectangles and circle
Primitives.
26
Decide where the origin will be located and then define the rectangle and circle primitives relative to that origin.
The location of the origin is arbitrary. Here, use the center of the upper left-hand hole. ANSYS does not need to
know where the origin is. Simply begin by defining a rectangle relative to that location. In ANSYS, this origin
is called the global origin.
1. Main Menu> Preprocessor> Modeling> Create> Areas> Rectangle> By Dimensions > Enter
the following:
X1 = 0 (Note: Press the Tab key between entries)
X2 = 6
Y1 = -1
Y2 = 1
Y2 = -3
4. OK to create the second rectangle and close the dialog box.
27
Step 2: Change plot controls and replot.
The area plot shows both rectangles, which are areas, in the same color. To more clearly distinguish between
areas, turn on area numbers and colors. The "Plot Numbering Controls" dialog box on the Utility Menu controls
how items are displayed in the Graphics Window. By default, a "replot" is automatically performed upon
execution of the dialog box. The replot operation will repeat the last plotting operation that occurred (in this
case, an area plot).
1. Utility Menu> Plot Ctrls> Numbering
2. Turn on area numbers.
Before going to the next step, save the work you have done so far. ANSYS stores any input data in
memory to the ANSYS database. To save that database to a file, use the SAVE operation, available as a
tool on the Toolbar. ANSYS names the database file using the format job name .db. If you started ANSYS
using the product launcher, you can specify a job name at that point (the default job name is file). You can
check the current job name at any time by choosing Utility Menu> List> Status> Global Status. You can
also save the database at specific milestone points in the analysis (such as after the model is complete, or
after the model is meshed) by choosing Utility Menu> File> Save As and specifying different job names
(model .db, or mesh.db, etc.).
It is important to do an occasional save so that if you make a mistake, you can restore the model
from the last saved state. You restore the model using the RESUME operation, also available on the
Toolbar. (You can also find SAVE and RESUME on the Utility Menu, under File.)
4. Toolbar: SAVE_DB.\
The next step in the model construction is to create the half circle at each end of the bracket. You
will actually create a full circle on each end and then combine the circles and rectangles with a Boolean
28
"add" operation (discussed in step 5.). To create the circles, you will use and display the working plane.
You could have shown the working plane as you created the rectangles but it was not necessary.
Before you begin however, first "zoom out" within the Graphics Window so you can see more of the
circles as you create them. You do this using the "Pan-Zoom-Rotate" dialog box, a convenient graphics control
box you’ll use often in any ANSYS session.
1. Utility Menu> PlotCtrls> Pan, Zoom, Rotate
6. Click on Polar.
Note
While you are positioning the cursor for picking, the "dynamic" WP X and Y values are displayed in the Solid
Circular Area dialog box. Also, as an alternative to picking, you can type these values along with the radius into
the dialog box.
Step 4: Move working plane and create second circle.
To create the circle at the other end of the bracket in the same manner, you need to first move the working plane
to the origin of the circle. The simplest way to do this without entering number offsets is to move the WP to an
average keypoint location by picking the keypoints at the bottom corners of the lower, right rectangle.
1. Utility Menu> WorkPlane> Offset WP to> Keypoints
2. Pick keypoint at lower left corner of rectangle.
3. Pick keypoint at lower right of rectangle.
3. Toolbar: SAVE_DB.
Step 6: Create line fillet.
31
1. Utility Menu> PlotCtrls> Numbering
32
10. Utility Menu> Plot> Lines
33
4. Main Menu> Preprocessor> Modeling> Create> Areas> Arbitrary> By Lines
5. Pick lines 4, 5, and 1.
34
2. Pick All for all areas to be added.
3. Toolbar: SAVE_DB.
Step 9: Create first pin hole.
1. Utility Menu> WorkPlane> Display Working Plane (toggle on)
From this area plot, it appears that one of the pin hole areas is not there. However, it is there (as
indicated by the presence of its lines), you just can't see it in the final display of the screen. That is
because the bracket area is drawn on top of it. An easy way to see all areas is to plot the lines instead.
8. Utility Menu> Plot> Lines
37
6. Material> Exit
38
5. OK to apply the element type and close the dialog box.
39
2. Add a real constant set.
3. OK for PLANE82.
Before clicking on the Help button in the next step, you should be aware that the help
information may appear in the same window as this tutorial, replacing the contents of the
tutorial. After reading the help information, click on the Back button to return to this tutorial.
If the help information appears in a separate window from the tutorial, minimize or close the
help window after you read the help information.
40
Generate Mesh
Step 17: Mesh the area.
One nice feature of the ANSYS program is that you can automatically mesh the model without specifying any
mesh size controls. This is using what is called a default mesh. If you’re not sure how to determine the mesh
density, let ANSYS try it first! Meshing this model with a default mesh however, generates more elements than
are allowed in the ANSYS ED program. Instead you will specify a global element size to control overall mesh
density.
1. Main Menu> Preprocessor> Meshing> Mesh Tool
3. Type in 0.5.
4. OK.
6. Click on Mesh.
7. Pick All for the area to be meshed (in picking menu). Close any warning messages that
appear.
Note
41
The mesh you see on your screen may vary slightly from the mesh shown here. As a result of this, you may see
slightly different results during postprocessing. For a discussion of results accuracy, see Planning Your
Approach in the ANSYS Modeling and Meshing Guide.
Step 18: Save the database as mesh.db.
Here again, you will save the database to a named file, this time mesh.db.
2. Pick the four lines around left-hand hole (Line numbers 10, 9, 11, 12).
2. Pick line defining bottom left p art of the circle (line 6).
3. Apply.
43
5. Enter 500 for optional value.
6. Apply.
7. Pick line defining bottom right part of circle (line 7).
8. Apply.
11. OK.
Obtain Solution
44
Step 21: Solve.
3. OK.
45
4. Utility Menu> Plot Ctrls> Animate> Deformed Shape
6. OK.
7. Make choices in the Animation Controller (not shown), if necessary, then choose Close.
4. OK.
46
You can also produce an animated version of these results:
5. Utility Menu> Plot Ctrls> Animate> Deformed Results
8. OK.
9. Make choices in the Animation Controller (not shown), if necessary, then choose Close.
Step 25: List reaction solution.
47
The value of 134.61 is comparable to the total pin load force.
RESULT:
Date :
AIM:
To determine the displacement and bending stress of a given axisymmetric component using Finite
Element Analysis bases ANSYS structure and view the displacement and bending stress plots.
48
The model will be that of a closed tube made from steel. Point loads will be applied at the Point loads
will be applied at the center of the top and bottom plate to make an analytical verification simple to calculate. A
3/4 cross section view of the tube is shown below
PROCEDURE:
4. Modeling
(a).Create Areas
Preprocessor > Modeling > Create > Areas > Rectangle > By Dimensions
For an axisymmetric problem, ANSYS will rotate the area around the y-axis at x=0. Therefore,
to create the geometry mentioned above, we must define a U-shape.
Rectangle X1 X2 Y1 Y2
1 0 20 0 5
2 15 20 0 100
3 0 20 95 100
(b) Add Areas Together
Preprocessor > Modeling > Operate > Booleans > Add > Areas > Pick All
5. Define Mesh Size
Preprocessor > Meshing > Size Cntrls > ManualSize > Areas > All Areas > Enter 2
For this example we will use an element edge length of 2mm.
6. Mesh the model
Preprocessor > Meshing > Mesh > Areas > Free > click 'Pick All'
Your model should know look like this:
Solution Phase: Assigning Loads and Solving
7. Define Analysis Type
Solution > Analysis Type > New Analysis > Static
8. Apply Constraints
a. Solution > Define Loads > Apply > Structural > Displacement > Symmetry B.C. > On Lines
Pick the two edges on the left, at x=0, as shown below.
50
b. Solution > Define Loads > Apply > Structural > Displacement > On Nodes > select two nodes at
the mid point of the model as shown below > In the window pick Apply > select Uy and Enter
displacement value = 0 > Ok
9. Apply Loads
a. Solution > Define Loads > Apply > Structural > Force/Moment > On Keypoints
Pick the top left corner of the area and click OK. Apply a load of 100 in the FY direction.
b. Solution > Define Loads > Apply > Structural > Force/Moment > On Keypoints
Pick the bottom left corner of the area and click OK. Apply a load of -100 in the FY direction.
The applied loads and constraints should now appear as shown in the figure below.
51
Solution > Solve > Current LS
11. Deflection
General Postproc > Plot Results > Contour Plot > Nodal Solu ... > DOF solution, > displacement
vector sum.> Ok
12. Von mises stress
General Postproc > Plot Results > Contour Plot > Nodal Solu ... > Stress > Von Mises Stress >
Ok
13. Plotting the Elements as Axisymmetric
Utility Menu > PlotCtrls > Style > Symmetry Expansion > 2-D Axi-symmetric...
The following window will appear. By clicking on 3/4 expansion you can produce the figure
shown at the beginning of this tutorial.
52
RESULT:
Ex. No. : 06 STRESS ANALYSIS OF CANTILEVER BEAM WITH POINT LOAD AT THE
END
Date:
AIM:
To determine the displacement and bending stress of a given Cantilever Beam using Finite Element
Analysis based ANSYS software and also plot shear force and bending moment diagrams.
53
PROCEDURE
Preprocessor > Element Type > Add/Edit/Delete > Add >Beam > 2 node 188> Ok > Options > pull
down K3 select Cubic Form > pull down K7 select All Section points > pull down K9 select All Section
points
Preprocessor > Material Props > Material Models > Structural > Linear > Elastic > Isotropic > Enter EX
= 2.068E11 and PRXY = 0.3> Ok
Preprocessor > Sections > Beam > Common sections > Pull down Sub- Type in the window > select
square section > Enter B = 0.01 and H = 0.01 > Preview > Ok
5. Modeling
Preprocessor > Modeling > Create > Key points > In Active CS > Key point number 1 > X= 0, Y= 0 and
Z = 0 > Apply > Key point number 2> X= 1, Y= 0 and Z =0 > Ok
54
6. Form a Line
Preprocessor > Modeling > Create > Lines > Lines > Straight Line >pick Key points 1 and 2 > Ok
Preprocessor > Meshing > size cntrls > Manual size > Lines > All Lines> Enter No. of Element
divisions = 20 > Ok
Preprocessor > Meshing > Mesh > Lines > Pick All
Preprocessor > Loads > Define loads >Apply > Structural > Displacement > On Key Points >select left
key point 1 > Ok > select All DOF > Enter Displacement Value = 0 > Ok
Preprocessor > Loads > Define loads >Apply > Structural > Force /Moment > On Key Points >select
right key point 2 > Ok > pull down select FY > Enter Force / Moment Value = -100 > Ok
55
General Postproc > Plot Results > Deformed Shape > select Def + undeformd > Ok
General Postproc > Plot Results > Contour Plot > nodal Solu > select DOF Solution > select
Displacement Vector sum > Ok
15. Stress
General Postproc > List Results > Element Solution > select Stress > select Von Mises stress >
Ok > Close
56
16. Shear Force Plot
General Postproc > Element Table > Define Table > Add > pull down left side select By
sequence num right side Enter SMISC, 6 > Apply > Again pull down left side select By
sequence num > right side Enter SMISC, 19 > Ok > Close
General Postproc > Plot Results > Contour Plot > Line Elem Res > select LabI Elem table item
at node I SMIS6 > select LabJ Elem table item at node J SMIS19 > Ok
57
General Postproc > Element Table > Define Table > Add > pull down left side select By
sequence num right side Enter SMISC, 3> Apply > Again pull down left side select By sequence
num > right side Enter SMISC, 16 > Ok > Close
General Postproc > Plot Results > Contour Plot > Line Elem Res > select LabI Elem table item
at node I SMIS3> select LabJ Elem table item at node J SMIS16
> Ok
RESULT:
Displacement vector sum =
Shear force =
Ex. No. : 07 STRESS ANALYSIS OF SIMPLY SUPPORTED BEAM WITH POINT LOAD AT THE
CENTRE
Date:
AIM:
To determine the displacement and bending stress of a given simply supported beam using Finite
Element Analysis based ANSYS software and also plot shear force and bending moment diagrams.
58
PROCEDURE
Preprocessor > Element Type > Add/Edit/Delete > Add >Beam > 2 node 188> Ok > Options > pull
down K3 select Cubic Form > pull down K7 select All Section points > pull down K9 select All Section
points > Ok > Close
Preprocessor > Material Props > Material Models > Structural > Linear > Elastic > Isotropic > Enter EX
= 2.068E11 and PRXY = 0.3> Ok
Preprocessor > Beam > Common sections > Pull down Sub- Type in the window > select square
section > Enter B = 0.01 and H = 0.01 > Preview > Ok
5. Modeling
Preprocessor > Modeling > Create > Key points > In Active CS > Key point number 1 > X= 0, Y= 0 and
Z = 0 > Apply > Key point number 2> X= 1, Y= 0 and Z Ok
6. Form a Line
59
Preprocessor > Modeling > Create > Lines > Lines > Straight Line >using mouse pick Key points 1 and
2 > Ok
Preprocessor > Meshing > size cntrls > Manual size > Lines > All Lines> Enter No. of Element
divisions = 20 > Ok
Preprocessor > Meshing > Mesh > Lines > Pick All
Preprocessor > Loads > Define loads >Apply > Structural > Displacement > On Key Points >select key
points 1 and 2 > Ok > select UX and UY > Enter Displacement Value = 0 > Ok
Preprocessor > Loads > Define loads >Apply > Structural > Force /Moment > On Nodes >using mouse
select Mid point of the line > Ok > pull down select FY > Enter Force / Moment Value = -100 > Ok
General Postproc > Plot Results > Deformed Shape > select Def + undeformd > Ok
General Postproc > Plot Results > Contour Plot > nodal Solu > select DOF Solution > select
Displacement Vector sum > Ok
15. Stress
General Postproc > List Results > Element Solution > select Stress > select Von Mises stress >
Ok > Close
61
16. Shear Force Plot
General Postproc > Element Table > Define Table > Add > pull down left side select By
sequence num > right side Enter SMISC, 6 > Apply > Again pull down left side select By
sequence num > right side Enter SMISC, 19 > Ok > Close
General Postproc > Plot Results > Contour Plot > Line Elem Res > select LabI Elem table item
at node I SMIS6 > select LabJ Elem table item at node J SMIS19
> Ok
62
General Postproc > Element Table > Define Table > Add > pull down left side select By
sequence num > right side Enter SMISC, 3 > Apply > Again pull down left side select By
sequence num > right side Enter SMISC, 16 > Ok > Close
General Postproc > Plot Results > Contour Plot > Line Elem Res > select LabI Elem table item
at node I SMIS3> select LabJ Elem table item at node J SMIS16
> Ok
RESULT:
Displacement vector sum =
Shear force =
63
Ex. No. : 08 STRESS ANALYSIS OF SIMPLY SUPPORTED BEAM WITH UNIFORMLY
DISTRIBUTED LOAD
Date:
AIM:
To determine the displacement and bending stress of a given stress analysis of simply supported beam
with uniformly distributed load using Finite Element Analysis based ANSYS software and also plot shear force
and bending moment diagrams.
PROCEDURE
Preprocessor > Element Type > Add/Edit/Delete > Add >Beam > 2 node 188> Ok > Options > pull
down K3 select Cubic Form > pull down K7 select All Section points > pull down K9 select All Section
points > Ok > Close
Preprocessor > Material Props > Material Models > Structural > Linear > Elastic > Isotropic > Enter EX
= 2.068E11 and PRXY = 0.3> Ok
5. Modeling
Preprocessor > Modeling > Create > Key points > In Active CS > Key point number 1 > X= 0, Y= 0 and
Z = 0 > Apply > Key point number 2> X= 1, Y= 0 and Z Ok
6. Form a Line
Preprocessor > Modeling > Create > Lines > Lines > Straight Line >using mouse pick Key points 1 and
2 > Ok
Preprocessor > Meshing > size cntrls > Manual size > Lines > All Lines> Enter No. of Element
divisions = 20 > Ok
Preprocessor > Meshing > Mesh > Lines > Pick All
Preprocessor > Loads > Define loads >Apply > Structural > Displacement > On Key Points >select key
points 1and 2 > Ok > select UX and UY > Enter Displacement Value = 0 > Ok
65
11. Apply Loads
Preprocessor > Loads > Define loads > Apply > Structural > Force / Moment > On Nodes > using
mouse select All the nodes of the line except first and last nodes > Ok > pull down select FY > Enter
Force / Moment Value = - 0.25 > Ok
66
VIEWING THE RESULTS
General Postproc > Plot Results > Deformed Shape > select Def + undeformd > Ok
General Postproc > Plot Results > Contour Plot > nodal Solu > select DOF Solution > select
Displacement Vector sum > Ok
67
15. Stress
General Postproc > List Results > Element Solution > select Stress > select Von Mises stress >
Ok > Close
General Postproc > Element Table > Define Table > Add > pull down left side select By
sequence num right side Enter SMISC, 6 > Apply > Again pull down left side select By
sequence num > right side Enter SMISC, 19 > Ok > Close
General Postproc > Plot Results > Contour Plot > Line Elem Res > select LabI Elem table item
at node I SMIS6 > select LabJ Elem table item at node J SMIS19
> Ok
68
17. Bending Moment Plot
General Postproc > Element Table > Define Table > Add > pull down left side select By
sequence num right side Enter SMISC, 3> Apply > Again pull down left side select By sequence
num > right side Enter SMISC, 16 > Ok > Close
General Postproc > Plot Results > Contour Plot > Line Elem Res > select LabI Elem table item
at node I SMIS3> select LabJ Elem table item at node J SMIS16 > Ok
RESULT:
Shear force =
69
Ex. No. : 09 STRESS ANALYSIS OF FIXED BEAM WITH POINT LOAD AT THE CENTRE
Date:
AIM:
To determine the displacement and bending stress of a given stress analysis of fixed beam with point
load at the centre using Finite Element Analysis based ANSYS software and also plot shear force and bending
moment diagrams.
PROCEDURE
Preprocessor > Element Type > Add/Edit/Delete > Add >Beam > 2 node 188> Ok > Options > pull
down K3 select Cubic Form > pull down K7 select All Section points > pull down K9 select All Section
points > Ok > Close
Preprocessor > Material Props > Material Models > Structural > Linear > Elastic > Isotropic > Enter EX
= 2.068E11 and PRXY = 0.3> Ok
70
4. Define Section Type
Preprocessor > Beam > Common sections > Pull down Sub- Type in the window > select square
section > Enter B = 0.01 and H = 0.01 > Preview > Ok
5. Modeling
Preprocessor > Modeling > Create > Key points > In Active CS > Key point number 1 > X= 0, Y= 0 and
Z = 0 > Apply > Key point number 2> X= 1, Y= 0 and Z Ok
6. Form a Line
Preprocessor > Modeling > Create > Lines > Lines > Straight Line >using mouse pick Key points 1 and
2 > Ok
Preprocessor > Meshing > size cntrls > Manual size > Lines > All Lines> Enter No. of Element
divisions = 20 > Ok
Preprocessor > Meshing > Mesh > Lines > Pick All
Preprocessor > Loads > Define loads >Apply > Structural > Displacement > On Key Points >select key
point 1 and 2 > Ok > select All DOF > Enter Displacement Value = 0 > Ok
71
11. Apply Loads
Preprocessor > Loads > Define loads >Apply > Structural > Force /Moment > On Nodes >using mouse
select Mid point of the line > Ok > pull down select FY > Enter Force / Moment Value = -100 > Ok
General Postproc > Plot Results > Deformed Shape > select Def + undeformd > Ok
72
14. Deflection plot
General Postproc > Plot Results > Contour Plot > nodal Solu > select DOF Solution > select
Displacement Vector sum > Ok
15. Stress
General Postproc > List Results > Element Solution > select Stress > select Von Mises stress >
Ok > Close
73
16. Shear Force Plot
General Postproc > Element Table > Define Table > Add > pull down left side select By
sequence num right side Enter SMISC, 6 > Apply > Again pull down left side select By
sequence num > right side Enter SMISC, 19 > Ok > Close
General Postproc > Plot Results > Contour Plot > Line Elem Res > select LabI Elem table item
at node I SMIS6 > select LabJ Elem table item at node J SMIS19 > Ok
General Postproc > Element Table > Define Table > Add > pull down left side select By
sequence num right side Enter SMISC, 3> Apply > Again pull down left side select By sequence
num > right side Enter SMISC, 16 > Ok > Close
General Postproc > Plot Results > Contour Plot > Line Elem Res > select LabI Elem table item
at node I SMIS3> select LabJ Elem table item at node J SMIS16 > Ok
74
RESULT:
Shear force =
75
Ex. No. : 10 MODE FREQUENCY ANALYSIS OF CANTILEVER BEAM
Date:
AIM:
To determine first three natural frequencies of Cantilever Beam using Finite Element Analysis
based ANSYS software and also plot three mode shapes.
PROCEDURE
Preprocessor > Element Type > Add/Edit/Delete > Add >Beam > 2 node 188> Ok > Options > pull
down K3 select Cubic Form > pull down K7 select All Section points > pull down K9 select All Section
points > Ok > Close
Preprocessor > Material Props > Material Models > Structural > Linear > Elastic > Isotropic > Enter EX
= 2.068E11 and PRXY = 0.3
76
4. Define Section Type
Preprocessor > Beam > Common sections > Pull down Sub- Type in the window > select square
section > Enter B = 0.01 and H = 0.01 > Preview > Ok
5. Modeling
Preprocessor > Modeling > Create > Key points > In Active CS > Key point number 1 > X= 0, Y= 0 and
Z = 0 > Apply > Key point number 2> X= 1, Y= 0 and Z Ok
6. Form a Line
Preprocessor > Modeling > Create > Lines > Lines > Straight Line >pick Key points 1 and 2 > Ok
Preprocessor > Meshing > size cntrls > Manual size > Lines > All Lines> Enter No. of Element
divisions = 20 > Ok
Preprocessor > Meshing > Mesh > Lines > Pick All
77
12. Apply Constrain
Preprocessor > Loads > Define loads >Apply > Structural > Displacement > On Key Points >select left
key point 1 > Ok > select All DOF > Enter Displacement Value = 0 > Ok
78
THREE MODE SHAPES
General Postproc > Read Results > First Set > Plot Results > Deformed Shape > select Def +
Undeformed > Ok
General Postproc > Read Results > Next Set > Plot Results > Deformed Shape > select Def +
Undeformed > Ok
79
General Postproc > Read Results > Next Set > Plot Results > Deformed Shape > select Def + Undeformed >
Ok
RESULT:
80
Ex. No. : 11 MODE FREQUENCY ANALYSIS OF SIMPLY SUPPORTED BEAM
Date:
AIM:
To determine the first three natural frequencies of simply supported Beam using Finite Element Analysis
based ANSYS software and also plot first three mode shapes.
PROCEDURE
Preprocessor > Element Type > Add/Edit/Delete > Add >Beam > 2 node 188> Ok > Options > pull
down K3 select Cubic Form > pull down K7 select All Section points > pull down K9 select All Section
points > Ok > Close
Preprocessor > Material Props > Material Models > Structural > Linear > Elastic > Isotropic > Enter EX
= 2.068E11 and PRXY = 0.3
Preprocessor > Beam > Common sections > Pull down Sub- Type in the window > select square
section > Enter B = 0.01 and H = 0.01 > Preview > Ok
81
5. Modeling
Preprocessor > Modeling > Create > Key points > In Active CS > Key point number 1 > X= 0, Y= 0 and
Z = 0 > Apply > Key point number 2> X= 1, Y= 0 and Z Ok
6. Form a Line
Preprocessor > Modeling > Create > Lines > Lines > Straight Line > pick Key points 1 and 2 > Ok
Preprocessor > Meshing > size cntrls > Manual size > Lines > All Lines> Enter No. of Element
divisions = 20 > Ok
Preprocessor > Meshing > Mesh > Lines > Pick All
Preprocessor > Loads > Define loads >Apply > Structural > Displacement > On Key Points >select left
key point 1 and select right key point 2 > Ok > select UX and UY > Enter Displacement Value = 0 > Ok
82
13. Solving the system
Solution > Solve > Current LS > Ok
General Postproc > Read Results > First Set > Plot Results > Deformed Shape > select Def +
Undeformed > Ok
83
General Postproc > Read Results > Next Set > Plot Results > Deformed Shape > select Def +
Undeformed > Ok
General Postproc > Read Results > Next Set > Plot Results > Deformed Shape > select Def +
Undeformed > Ok
84
RESULT:
85
Ex. No. :12 MODE FREQUENCY ANALYSIS OF FIXED BEAM
Date:
AIM:
To first three natural frequencies of fixed Beam using Finite Element Analysis based ANSYS
software and also plot first three mode shapes.
PROCEDURE
Preprocessor > Element Type > Add/Edit/Delete > Add >Beam > 2 node 188> Ok > Options > pull
down K3 select Cubic Form > pull down K7 select All Section points > pull down K9 select All Section
points > Ok > Close
Preprocessor > Material Props > Material Models > Structural > Linear > Elastic > Isotropic > Enter EX
= 2.068E11 and PRXY = 0.3
Enter Density DENS = 7830 > Ok
4. Define Section Type
Preprocessor > Beam > Common sections > Pull down Sub- Type in the window > select square
section > Enter B = 0.01 and H = 0.01 > Preview > Ok
86
5. Modeling
Preprocessor > Modeling > Create > Key points > In Active CS > Key point number 1 > X= 0, Y= 0 and
Z = 0 > Apply > Key point number 2> X= 1, Y= 0 and Z Ok
6. Form a Line
Preprocessor > Modeling > Create > Lines > Lines > Straight Line >pick Key points 1 and 2 > Ok
Preprocessor > Meshing > size cntrls > Manual size > Lines > All Lines> Enter No. of Element
divisions = 20 > Ok
Preprocessor > Meshing > Mesh > Lines > Pick All
87
12. Apply Constrain
Preprocessor > Loads > Define loads >Apply > Structural > Displacement > On Key Points >select left
key point 1 and right key point 2 > Ok > select All DOF > Enter Displacement Value = 0 > Ok
88
THREE MODE SHAPES
General Postproc > Read Results > First Set > Plot Results > Deformed Shape > select Def +
Undeformed > Ok
General Postproc > Read Results > Next Set > Plot Results > Deformed Shape > select Def +
Undeformed > Ok
89
General Postproc > Read Results > Next Set > Plot Results > Deformed Shape > select Def +
Undeformed > Ok
RESULT:
90
Ex. No. : 13. HARMONIC ANALYSIS OF A CANTILEVER BEAM
Date:
To perform harmonic analysis of Fixed Beam using Finite Element Analysis based ANSYS
software and also plot Amplitude Vs Frequency graph .
PROCEDURE
Preprocessor > Element Type > Add/Edit/Delete > Add >Beam > 2 node 188> Ok > Options > pull
down K3 select Cubic Form > pull down K7 select All Section points > pull down K9 select All Section
points > Ok > Close
Preprocessor > Material Props > Material Models > Structural > Linear > Elastic > Isotropic > Enter EX
= 2.068E11 and PRXY = 0.3
Enter Density DENS = 7830 > Ok
91
4. Define Section Type
Preprocessor > Beam > Common sections > Pull down Sub- Type in the window > select square
section > Enter B = 0.01 and H = 0.01 > Preview > Ok
5. Modeling
Preprocessor > Modeling > Create > Key points > In Active CS > Key point number 1 > X= 0, Y= 0 and
Z = 0 > Apply > Key point number 2> X= 1, Y= 0 and Z Ok
6. Form a Line
Preprocessor > Modeling > Create > Lines > Lines > Straight Line >pick Key points 1 and 2 > Ok
Preprocessor > Meshing > size cntrls > Manual size > Lines > All Lines> Enter No. of Element
divisions = 20 > Ok
Preprocessor > Meshing > Mesh > Lines > Pick All
92
12. Apply Loads
Preprocessor > Loads > Define loads >Apply > Structural > Force / Moment > On Key Points >select
right key point 2 > Ok > select FY > Real part of force/mom = 100 and Imag part of force/mom = 0 >
Ok
93
13. Set the frequency range
Solution > Load Step Opts > Time/Frequency > Freq and Substeps > Enter Harmonic freq range 0 To
100 > Enter Number of substeps = 100 > select Stepped b.c.
TimeHist Postpro > Time History Variables – file .rst window should pop up as shown.
94
Select Add (the green '+' sign in the upper left corner) from this window and the following
window should appear
Nodal Solution > DOF Solution > Y-Component of displacement. Click OK.
o Graphically select right key point 2 when prompted and click OK. The 'Time History Variables'
window should now look as follows
95
2. List Stored Variables
o In the 'Time History Variables' window click the 'List' button, 3 buttons to the left of 'Add'
The following window will appear listing the data:
96
Note that we get peaks at frequencies of approximately 8.3 and 51 Hz. This corresponds with the
predicted frequencies of 8.311 and 51.94Hz.
To get a better view of the response, view the log scale of UY.
o Select Utility Menu > PlotCtrls > Style > Graphs > Modify Axis
The following window will appear
o As marked by an 'A' in the above window, change the Y-axis scale to 'Logarithmic'
97
o Select Utility Menu > Plot > Replot
o You should now see the following
This is the response at node 2 for the cyclic load applied at this node from 0 - 100 Hz.
RESULT:
98
Ex. No. : 14. THERMAL STRESS ANALYSIS OF A 2D COMPONENT – STATIC
Date :
AIM:
To determine the thermal stress of a given component using FEA based ANSYS software.
A steel link, with no internal stresses, is pinned between two solid structures at a reference temperature
of 273 K. One of the solid structures is heated to a temperature of 348 K. As heat is transferred from the solid
structure into the link, the link will attempt to expand. However, since it is pinned this cannot occur and
as such, stress is created in the link. A steady-state solution of the resulting stress will be found to simplify the
analysis.
Loads will not be applied to the link, only a temperature change of 348 K. The link is steel with a modulus of
elasticity of 200 GPa, a thermal conductivity of 60.5 W/m*K and a thermal expansion coefficient of 12e-6 /K.
PROCEDURE:
99
Preprocessor > Material Props > Material Models > Thermal > Conductivity > Isotropic > KXX
= 60.5
6. Modeling - Define Keypoints
Preprocessor > Modeling > Create > Keypoints > In Active CS > Key point number 1, X=0, Y=0
and Z=0 > Apply
Preprocessor > Modeling > Create > Keypoints > In Active CS > Key point number 2, X=1, Y=0
and Z=0 > Ok
7. Create Lines
Preprocessor > Modeling > Create > Lines > Lines > Straight Line > pick Key point number 1
and 2 > Ok
8. Define Mesh Size
Preprocessor > Meshing > Size Cntrls > ManualSize > Lines > All Lines > Enter No. of element
divisions = 20
9. Mesh the frame
Preprocessor > Meshing > Mesh > Lines > click 'Pick All'
10. Write Environment
(The thermal environment (the geometry and thermal properties) is now fully described and can
be written to memory to be used at a later time).
Preprocessor > Physics > Environment > Write
In the window that appears, enter the TITLE Thermal and click OK.
100
12. Switch Element Type
Preprocessor > Element Type > Switch Elem Type > Choose Thermal to Struc from the scroll
down list. > Close
(This will switch to the complimentary structural element automatically. In this case it is LINK
8. For more information on this element, see the help file. A warning saying you should modify
the new element as necessary will pop up. In this case, only the material properties need to be
modified as the geometry is staying the same).
13. Define Element Material Properties
Preprocessor > Material Props > Material Models > Structural > Linear > Elastic > Isotropic >
EX = 200e9 and PRXY = 0.3
Preprocessor > Material Props > Material Models > Structural > Thermal Expansion > Secant
Coefficient > Isotropic > ALPX = 12e-6 > Ok > Close
14. Write Environment
The structural environment is now fully described.
Preprocessor > Physics > Environment > Write
In the window that appears, enter the TITLE Struct
Solution Phase: Assigning Loads and Solving
15. Define Analysis Type
Solution > Analysis Type > New Analysis > select Static > Ok
16. Read in the Thermal Environment
Solution > Unabridged Menu > Physics > Environment > Read > Choose Thermal and click
OK.
(If the Physics option is not available under Solution, click Unabridged Menu at the bottom of the
Solution menu. This should make it visible).
17. Apply Constraints
Solution > Define Loads > Apply > Thermal > Temperature > On Key points > select Keypoint
1> Ok > select TEMP > Enter TEMP value = 348 > Ok
101
18. Solve the System
(It is very important to click Finish as it closes that environment and allows a new one to be
opened without contamination. If this is not done, you will get error messages).
General Postproc > Plot Results > Contour Plot > Nodal Solu > DOF solution > Nodal
Temperature > Ok
(The thermal solution has now been obtained. If you plot the steady-state temperature on the link, you
will see it is a uniform 348 K, as expected. This information is saved in a file labelled Jobname.rth,
were .rth is the thermal results file. Since the jobname wasn't changed at the beginning of the analysis,
this data can be found as file.rth. We will use these results in determing the structural effects).
Solution > Physics > Environment > Read > Choose struct and click OK.
Solution > Define Loads > Apply > Structural > Displacement > On Key points > select Key
point 1 > Ok > select All DOF > Enter displacement value = 0 > Ok
Solution > Define Loads > Apply > Structural > Displacement > On Key points > select Key
point 2 > Ok > select UX > Enter displacement value = 0 > Ok
(As shown below, enter the file name as file.rth. This couples the results from the solution of
the thermal environment to the information prescribed in the structural environment and uses it
during the analysis).
102
24. Define Reference Temperature
Preprocessor > Loads > Define Loads > Settings > Enter Reference Temp = 273 > Ok
103
2. List the Stress Data
General Postproc > Element Table > List Elem Table > COMPSTR > OK
The following list should appear. Note the stress in each element: -0.180e9 Pa, or 180 MPa in
compression as expected.
RESULT:
Thermal stress =
104
Ex. No. :15 CONDUCTIVE HEAT TRANSFER ANALYSIS OF A 2D COMPONENT
Date:
AIM:
To perform conductive heat transfer analysis of a given 2D component using FEA based ANSYS
software and plot temperature distribution.
PROCEDURE:
The Simple Conduction Example is constrained as shown in the following figure. Thermal conductivity (k) of
the material is 10 W/m*C and the block is assumed to be infinitely long.
105
3. Element Material Properties
Preprocessor > Material Props > Material Models > Thermal > Conductivity > Isotropic > KXX = 10
(Thermal conductivity)
4. Modeling
Preprocessor > Modeling > Create > Areas > Rectangle > By 2 Corners > X=0, Y=0, Width=1,
Height=1
5. After modeling is done save the model on a new folder
Ansys utility menu > plot controls > write metafile > invert white/black
6. Mesh Size
Preprocessor > Meshing > Size Cntrls > Manual Size > Areas > All Areas > 0.05
7. Mesh
Preprocessor > Meshing > Mesh > Areas > Free > Pick All
8. After meshing is done save the meshed model on a previous new folder
Ansys utility menu > plot controls > write metafile > invert white/black > Save
Fill the window in as shown to constrain the side to a constant temperature of 500
Solution > Define Loads > Apply > Thermal > Temperature > On lines > using cursor select bottom
horizontal line , left vertical line and right vertical line > ok
106
Fill the window in as shown to constrain the side to a constant temperature of 100
Orange triangles in the graphics window indicate the temperature contraints.
11. After boundary condition and loading is done save the same on a previous new folder
Ansys utility menu > plot controls > write metafile > invert white/black > Save
14. Ansys utility menu > plot controls > animate > deformed results > dof solution > nodal temp
RESULT:
107
Ex. No. : 16 CONVECTIVE HEAT TRANSFER ANALYSIS OF A 2D COMPONENT
Date :
AIM:
To perform convective heat transfer analysis of a given 2D component using FEA based ANSYS
software and plot temperature distribution.
PEROCEDURE:
108
Preprocessor > Modeling > Create > Areas > Rectangle > By 2 Corners > X=0, Y=0, Width=1,
Height=1
7. Mesh
Preprocessor > Meshing > Mesh > Areas > Free > Pick All
8. After meshing is done save the meshed model on a previous new folder
Ansys utility menu > plot controls > write metafile > invert white/black
9. Define Analysis Type
Loads > Analysis Type > New Analysis > Steady-State > ok
3. Fill in the window as shown. This will specify a convection of 10 W/m2*C and an ambient
temperature of 100 degrees Celcius. Note that VALJ and VAL2J have been left blank. This is
because we have uniform convection across the line.
109
12. Apply Insulated Boundary Conditions
1. Solution > Define Loads > Apply > Thermal > Convection > On Lines
2. Select the bottom line of the block.
3. Enter a constant Film coefficient (VALI) of 0. This will eliminate convection through the side,
thereby modeling an insulated wall. Note: you do not need to enter a Bulk (or ambient)
temperature.You should obtain the following:
13. After boundary condition and loading is done save the same on
a previous new folder
Ansys utility menu > plot controls > write metafile > invert white/black > Save
14. Solve the System
Solution > Solve > Current LS > Ok > Close
Plot Temperature
General Postproc > Plot Results > Contour Plot > Nodal Solu ... > DOF solution, Temperature
TEMP
RESULT:
110
Ex. No. : 17 ANALYSIS OF FLUID FLOW OVER A HOLE
Date:
AIM:
To perform fluid flow analysis of a given 2D component using FEA based ANSYS software and plot
velocity distribution and pressure distribution.
PROCEDURE
111
Preprocessor > Modeling > Create > Areas > Circle > Solid Circle > WP X= 1 WP Y=0.5, and Radius =
0.2
(C).Numbering Areas
Utility Menu >plot controls > Numbering> pick Areas
(D).Subtraction
Now we want to subtract the circle (2) from the rectangle (1).
Modeling > Operate > Booleans > Subtract > Areas > Enter 1 > ok> Enter 2 > ok
4. Mesh Size
Preprocessor > Meshing > Mesh Tool > Close
5. Mesh
Preprocessor > Meshing > Mesh > Areas > Free > Pick All
6. Apply Loads
Preprocessor > Loads > Define Loads > Apply > Fluid /CFD > Velocity > On Lines > pick the
left edge of the plate > Ok > Enter VX = 1 > Ok
Preprocessor > Loads > Define Loads > Apply > Fluid /CFD > Velocity > On Lines > pick edges
around the circle > Ok Enter VX = 0 and Enter VY = 0 > Ok
Preprocessor > Loads > Define Loads > Apply > Fluid /CFD > Pressure DOF > On Lines > pick
the top, bottom and right edges of the plate > Ok > Ok
112
7. Solution
Solution > FLOTRAN CFD Set Up > Fluid Properties > a dialog box appears in that select
against density as Liquid and against Viscosity as Liquid > Ok
Then another dialog box appears in that Enter the value of Density (Nominal value) = 1000 and
Viscosity (Nominal value) = 0.001 > Ok
Solution > FLOTRAN CFD Set Up > Execution Ctrl > A dialog box appears in that Enter in the
first row Global Iterations = 200 > Ok
8. Velocity Distribution
General Postproc > Plot Results > Contour Plot > Nodal Solution > Select DOF solution > select
Fluid Velocity > Ok
113
9. Velocity Vector Plot
General Postproc > Plot Results > Contour Plot > Vector Plot >Predefined
General Postproc > Plot Results > Contour Plot > Nodal Solution > Select DOF solution > select
Pressure > Ok
RESULT:
114
EX.NO.18: STUDY OF BASICS OF MATLAB
DATE:
AIM:
INTRODUCTION
Known for its highly optimized matrix and vector calculations, MATLAB offers on intuitive languages
for expressing problems and their solutions both mathematically and visually. Typically uses include:
In this chapter, We will introduce the MATLAB environment, We will learn how to create , edit, save,
run, and debug m-files (ASCII files with series of MATLAB statements). We will see how to create arrays
(matrices and vectors), and explore the built-in MATLAB linear algebra functions for matrix and vector
multiplication, do not cross products, transpose, determinates, and inverses and for the solution linear
equations. MATLAB is based on the language c, but is generally much easier to use. We will also see how to
program logic constructs and oops in MATLAB, how to use subprograms and functions, and how to use
comments (%) for explaining the programs and tabs for easy readability, and how to print and plot graphics
both two and three dimensional MATLAB's functions for symbolic mathematics are presented. use of these
functions to perform symbolic operations, to develop closed from expression for solution to algebraic equations,
ordinary differential equations , and system equation for presented . Symbolic mathematics can be used to
determine analytical expression for the derivative and integral of an expressions.
115
Starting and Quitting MATLAB
To start MATLAB click on the MATLAB icon or type in MATLAB , followed by pressing the enter or return
key at the system prompt. the screen will produce the MATLAB prompt >>(or EDU>>), which indicates that
MATLAB is waiting for a command to be entered.
in order to quit MATLAB, type quit or exit after prompt , followed by pressing the enter or return key.
Display Windows
1. A command Windows which is used to enter commands and data to display plots and graphs.
3. A Edit window which used to crate and modify m-files. m-flies are the files that contain a program are script
of MATLAB commands.
Entering Commands
Every command has to be followed by a carrier return <cr> (enter key) in order that the command can be
executed. MATLAB command are case sensitive and lower case letters are used throughout.
To execute an M-files (such as Project_1.m ). simply enter the name of the file without its extension (as in
project_1).
MATLAB expo
In order to see some of the, MATLAB capabilities , enter the demo command this will initiate the MATLAB
expo , MATLAB Expo is a graphical demonstration environment that shows the some of the different type of
operations which can be conducted with MATLAB.
Abort
In order to abort a command in MATLAB , hold down the control key and press c to generate a local abort with
MATLAB.
If a semicolon (;) is typed at the end of the command , the output of the command is not displayed.
Typing %
When percent symbol (%) is typed in the beginning of a line, the line is designated as a command . W.....hen
the enter key is pressed , the line is not executed.
116
The clc Command
The typing clc command and pressing enter cleans the command windows. once the clc command is executed a
clear windows is displayed.
Help
The MATLAB has a host of bulit in fuctions. For complete list , refer to MATLAB user's guide or refer to
online Help . To obtain the help on the particular topic in the list, eg. inverse , type help inv.
the equal sign implies the asssign ment of the expression to the variable. for instance to enter a 2x2
the statement is executed after the carriage return (or enter ) key is pressed to display
A=
1 2
3 4
ARITHMATIC OPERATION
The symbols for arithmetic operations with scalars are summarized below in tables 2.1
Table:
117
Table Common Math Functions
Function Description
Function Description
118
Table trigonometric and hyperbolic functions
Function Description
119
equal to x+√𝑥 2 − 1
Function description
Workplace information
function description
120
clc clear command window, command histo0ry
is lost
ARRAYS
An array ia a list of numbers arranged in rows and or columns. a one dimensional arrray is a row or a column of
numbers and a two dimensional array has a set of numbers arranged in rows and columns. an array operation is
performed element by element.
ROW VECTOR
In a row vector the elements are entered with a space or a comma between the elements inside the square
brackets. for example,
x=[7 -1 2 -5 8]
COLUMN VECTOR
In a column vector the elements or enterd with asemicolun between the elements inside the square brackets. for
example,
MATRIX
A matrix is a two dimensional array which has numbers in rows and columns. A matrix is a enterd a row wise
with consecutive elements of a rows sepearted by a space or a comma, and the rows seperated by a semi colon
or carriage returns, the entire matrix is enclosed with in square brackets, in the elements of matrix may be real
numbers or comples numbers. for example to enter the matrix
1 3 −4
A=[ ]
0 −2 8
A=[1 3 -4; 0 -2 8]
121
The matlab input command is
ADDRESING ARRAYS
A colon can be used in mat lab to addres a range of elements in a vector or a matrix
Va(:) - refers to all the elements of the vector Va (either a row or a column vector)
For instance
>> U= V(2:8)
U= 5 -1 11 8 4 7 -3 11
Command Description
A(:,n) refers to the elements in alll the rows of a coloumn n of the matrix A
A(n,:) Refers to the elements in all the columns of row n of the matrix A
A(:,m:n) Refers to the elements in all the rows between coloumns m and n of the
matrix A
Refers to the elements in all the coloumns between rows m and n of the
A(m:n, :) matrix A
Refers to the elements in all the rows m through n and coloumns p through
A(m:n, p:q) q of the matrix A
122
A variable that exists as a vector, or a matrix, can be changed by adding elements to it. Addition of elements is
done by assigining values of the additional elements, or by appending existing varibales . rows and or coloumns
can be added to an existing matrix by assigning values to the new rows or columns.
DELETING ELEMENTS
An element, or a range of elements. of an existing variable can be deleted by reassigning blanks to these
elements. this is done simply by the use of square brackets with nothing typed in between them.
BUILT-IN FUNCTIONS
Some of the built-in functions available in MATLAB for managing and handling arrays as listed
Function Description
Size(A) Returns a row vector [m,n], Where m and n are the size mxn of the array A.
Reshape(A,m,n) Rearrange a matrix A that has r rows and a coloumns to have m rows and n
columns r times s must be equal to m times n.
Diag(v) When v is a vector, create a square matrix with the elements of v in the
diagonal
We consider here matrices that have than one row and more than one column
The addition ( the sum) or the subtraction (the difference) of the two arrays is obtained by adding or subtracting
their corresponding elements. These operations are performed with arrays of identiacal size (same number of
rows and columns.)
123
𝑎11 + 𝑏11 𝑎12 + 𝑏12 𝑎13 + 𝑏13
[ ]
𝑎21 + 𝑏21 𝑎22 + 𝑏22 𝑎23 + 𝑏23
DOT PRODUCT
The product is a scalar computed from two vectors of the same size. the scalar is the sum of the products of the
values in corresponding positions in the vectors.
dot (A,B) computes the dot product of A and B. if A and B are matrices , the dot product is a vector containing
the dot products for the corresponding columns of A and B
ARRAY MULTIPLICATION
The value in positon ci,j of the product C of two matrices , A and B, is the dot product of row I of the first matrix
and column j of the second matrix:
Array division
The division operation can be explained by means of the identity matrix and the inverse matrix operation .
Identity matrix
An identity matrix is a square matrix in which all the diagonal elements are 1’ds, and the remaining elements
are 0’s. if a matrix A is square, then it can be multiplied by the identity matrix, I, from the left or from the right
AI=IA=A
Inverse of a matrix
The matrix B is the inverse of the matrix A if when the two matrices are multiplied the product is the identity
matrix. Both matrices A and B must be square and the order of the multiplication can be AB or BA
AB=BA=I
Transpose
The transpose of a matrix is a new matrix in which the rows of the orginal matrix are the columns of the new
matrix. The transopse of a given matrix A is denoted by AT. in MATLAB, the transpose of the matrix A is
denoted by A’
124
Determinant
A determinant is a scalar computed from the entries in a square matrix. For a 2x2 matrix A, the determinant is
|A| = a11a22-a21a12
Array Division
MATLAB has two types of array divisions, which are the left division and the right division.
Left division
The left division is used to solve the matrix equation Ax=B where x and B are column vectors.
A-1Ax=A-1 B
or Ix = ᵪ = A-1 B
In MATLAB, the above equation is written by using the left division character:
ᵪ = A\B
Right Division
The Right division is used to solve the matrix equation xA = B where x and B are row vectors.
ᵪ = B . A-1
or
ᵪ=A/B
The values of λ for which X are nonzero are called the eigenvalues of the matrix A, and
(A – λI) X = 0
Equation and has nontrivial solutions only if the determinant is equal to zero, or
│A – λI│ = 0
Equation (2.3) is known as the characteristic equation of the matrix A. The solution to
The values of Qand d are such thatQ*Qis the identity matrix and A*X
126
Element – by element operations
Arithmetic operations
+ Addition + Addition
- Subtraction - Subtraction
Matrix Division
The solution to the matrix equation AX = B is obtained using matrix division , or X = A/B. The vector X
then contains the values of x
Matrix Inverse
For the solution of the matrix equation AX = B , we premultiply both sides of the equation by A-1
A-1AX = A-1B
Or IX = A-1B
127
Where I is the identity matrix
Hence X = A-1B
In MATLAB , we use the command x = inv (A)*B. Similarly , for XA = B, we use the command x=
B*inv (A)
The basic computional unit in MATLAB is the matrix . A matrix expression is enclosed in square
brackets , [ ].Blanks or commas seprate the column elements , and semisolons or carriage return separate the
rows.
SCRIPT FILES
A script is a sequence of ordinary statement and functions used at the command prompt level. A Script
is invoked at the command prompt level by typing the file-name or by using the pull down menu. Script can
also invoke other scripts.
The commands in the command window cannot be saved and executed again. Also, the command
window is not interactive. To overcome these difficulties, the procedure is first to create a file with a list of
command, save it, and then run the file. In this way the commands contained are executed in the order they are
listed when the file is run. In addition, as the need arises, one can change or modify the commands in the file,
the file can be saved and run again the file that are used in this fashion are known as script file. Thus, a script
file is a text file that contains a sequence of MATLAB commands. Script file can be edited (corrected and/or
changed)and executed many times.
Any text editor can be used to create script files. In MATLAB script file are created and edited in the
Editor/Debugger window .this window can be opened from the command window, select file, New, and then
M-file. Once the window is open, the commands of the script file are typed line. The commands can also be
typed in any text editor or word processor program and then copied and pasted in the edit/debugger window.
The second type of M-File is the function file. Function file enables the user to extend the basic library function
by adding one’s own computational procedures. Function M-files are expected to return one or more results.
Script files and function files may include reference to other MATLAB toolbox routines.
Before a script file can be executed it must be saved. All script files must be saved with the extension “.m”.
MATLAB refers to them as m-files. When using MATLAB M-files editor, the files will automatically be saved
with the “.m” extension. If any other text editor is used, the file must be saved with the “.m” extension, or
MATLAB will not be able to find and run the script file. This is done by choosing save As… from the file
128
menu, selecting a location, and entering a name for the file. The names of user defined variables, predefined
variables, MATLAB commands or functions should not be used to name script files.
A script file can be executed either by typing its name in the command window and then pressing the enter
key, directly from the Editor Window by clicking on the Run icon. File The is assumed to be in the current
directly, or in the search path.
Output commands
There are two commands that are commonly used to generate output. They are the disp and fprintf
commands.
PROGRAMMING IN MATLAB
One most significant of MATLAB is its extendibility through user-written programs such as the M-files. M-
files are ordinary ASCII text files written in MATLAB language. A function file is a subprogr
A relational operator compares two numbers by finding whether a comparison statement is true or false. A
logical operator examines true/false statements and produces a result which is true or false according to the
specific operator. Relational and logical operators are used in mathematical expressions and also in combination
with other commands, to make decisions that control the flow of a computer program.
129
Relational operators
Relational
Interpretation
operators
== Equal
̴= Not equal
Logical operators
& AND Operators on two operands (A and B). If both are true, the result
is true (1), otherwise the result is false (0).
Example: A&B
130
Order of precedence
Precedence Operation
2 Exponentiation
3 Logical NOT ( ̴)
4 Multiplication, Division.
5 Addition, Subtraction.
The MATLAB built-in functions which are equivalent to the logical operators are:
Or (A, B) Equivalent to A I B
GRAPHICS
MATLAB has many commands that can be used to create basic 2-D plots, overlay plots, specialized 2-D plots,
3-D plots, mesh, and surface plots.
Where x value and y values are vectors containing the x-and y-coordinates of points on the graph.
131
Style option is an optional argument that specifies the color, line-style, and the point-marker style.
The style option in the plot command is a character string that consists of 1,2 or 3 characters that specify the
color and/or the style. The different color, line-style and marker style option are summarized in table
There are several specialized graphics function available in MATLAB for 2-D plots. The list of functions
commonly used in MATLAB for plotting x-y data are in Table.
Function Description
132
Contourf Makes filled contour plots.
command Description
Overlay plots
There are three ways of generating overlay plots in MATLAB, they are
(a)Plot command
133
(b)Hold command
(c)Line command
(a)Plot command. Example E2.7(a) shows the use of plot command used with matrix argument, each
column of the second argument matrix plotted against the corresponding column of the first argument matrix.
(b)Hold command . invoking hold on at any point during a session freezes the current plot in the graphics
window. All the next plots generated by the plot command are added to the exiting plot. See Example E2.7(a).
(c)Line command. The line command takes a pair of vectors (or a triplet in 3-D) followed by a parameter
name/parameter value pairs as argument. For instance, the command: line (x data, y data, parameter name,
parameter value) adds lines to the existing axes. See Example E2.7(a).
3-D plots
MATLAB provides various options for displaying three-dimensional data. They include line and wire, surface,
mesh plots, among many others. More information can be found in the Help window under plotting and Data
visualization. Table lists commonly used function.
command Description
command Description
Mesch,meshz If the xy grid is rectangular, these two function are merely variations of
the basic plotting program mesh, and they operate in an identical
fashion. Meshc will produce a corresponding contour plot drawn on the
xy plane below the three dimensional figure, and meshz will add a
134
vertical wall to the outside features of the figures drawn by mesh.
This function is related to surf in the same way that meshc is related to
mesh.
Axis(‘image’) Alters the aspect ratio and the scaling so the screen
pixels are
135
square shaped rather than rectangular.
Plot3
Grid
slice
136
Result :- Thus the basic commands and codes of MATLAB were studied.
137
EX.NO.19: DETERMINATION OF MATRIX OPERATIONS
DATE:
AIM:
1 0 1 7 4 2
Consider two matrices A = [ 2 3 4 ] and B = [ 3 5 6 ] Using MATLAB, determine the following,
− 1 6 7 − 1 2 1
(a) A+B, (b) AB, (c) A , (d) A , (e)B , (f) B A , (g) A2+B2-AB, and (h) determinant of A, determinant of B
2 T -1 T T
and determinant of AB
SOLUTION
A =1 0 1
2 3 4
-1 6 7
B =7 4 2
3 5 6
-1 2 1
>> C=A+B
C =8 4 3
5 8 10
-2 8 8
>> D=A*B
D =6 6 3
19 31 26
4 40 41
>> E=A^2
138
E =0 6 8
4 33 42
4 60 72
>> F=A'
F= 2 -1
0 3 6
1 4 7
>> H=inv(B)
>> J=A'*B'
13 7 2
24 51 12
37 65 14
>> I=B'*A'
I =6 19 4
6 31 40
3 26 41
>> K=A^2+B^2-A*B
K =3 52 45
15 51 58
-2 28 42
>> det(A)
ans = 12
139
>> det(B)
ans = -63.0000
>> det(A*B)
ans = -756.0000
(b) AB =
(c) A2=
(d) AT =
(e)B-1 =
(f) BTAT =
(g) A2+B2-AB =
(h) Determinant of A=
Determinant of B =
Determinant of AB =
140
EX.NO.20: DETERMINATION OF EIGEN VALUES AND EIGEN VECTORS
DATE:
AIM:
4 2 −3 7 4 2
A = [ −1 1 3 ] and B = [ 3 5 6 ]
2 5 7 1 2 1
Solution
A =4 2 -3
-1 1 3
2 5 7
>> B=[1 2 3; 8 7 6; 5 3 1]
B =1 2 3
8 7 6
5 3 1
>> eig(A)
ans =0.5949
3.0000
8.4051
>> lamda=eig(A)
lamda = 0.5949
3.0000
8.4051
141
>> [v,d]=eig(A)
d = 0.5949 0 0
0 3.0000 0
0 0 8.4051
Result:-
Eigenvalues =
Eigenvectors =
142
EX.NO.21: SOLUTION OF SIMULTANEOUS EQUATIONS
DATE:
AIM:
x1+2x2+3x3+5x4=21
-2x1+5x2+7x3-9x4=18
5x1+7x2+2x3-5x4=25
-x1+3x2-7x3+7x4=30
Solution
[A][x] = [B]
1 2 3 5 𝑥1 21
−2 5 7 − 9 𝑥2 18
[ ]x[ ]=[ ]
5 7 2 − 5 𝑥3 25
−1 3 − 7 7 𝑥4 30
[x] = [A]-1B
A= 1 2 3 5
-2 5 7 -9
5 7 2 -5
-1 3 -7 7
B= 21
18
25
30
143
>> X=inv(A)*B
X= -1.5130
5.9108
0.3762
1.9126
>> check=A*X
check =
21.0000
18.0000
25.0000
30.0000
Result:-
144
Mesh plot
145
EX.NO.22: PLOT 2-D AND 3-D GRAPHS
DATE:
AIM:
2 2
To plot the function Z = 2−1.5√𝑥 +𝑦 sin(x) cos(0.5y) over the domain -4 ≤ x ≤ 4 and -4 ≤ y ≤ 4.
Solution :-
>> x=-4:0.25:4;
>> y=-4:0.25:4;
>> [x,y]=meshgrid(x,y);
>> z=2^(-1.5*sqrt(x^2+y^2))*cos(0.5*y)*sin(x);
>> mesh(x,y,z)
146
(b) Surface Plot
>> x=-4:0.25:4;
147
>> y=-4:0.25:4;
>> [x,y]=meshgrid(x,y);
>> z=2^(-1.5*sqrt(x^2+y^2))*cos(0.5*y)*sin(x);
>> surf(x,y,z)
>> x=-4:0.25:4;
>> y=-4:0.25:4;
>> [x,y]=meshgrid(x,y);
>> z=2^(-1.5*sqrt(x^2+y^2))*cos(0.5*y)*sin(x);
>> meshz(x,y,z)
148
(e) Surface and contour plot
>> x=-4:0.25:4;
>> y=-4:0.25:4;
>> [x,y]=meshgrid(x,y);
>> z=2^(-1.5*sqrt(x^2+y^2))*cos(0.5*y)*sin(x);
>> meshc(x,y,z)
>> x=-4:0.25:4;
>> y=-4:0.25:4;
>> [x,y]=meshgrid(x,y);
149
>> z=2^(-1.5*sqrt(x^2+y^2))*cos(0.5*y)*sin(x);
>> surfc(x,y,z)
150
(g) Water fall plot
>> x=-4:0.25:4;
>> y=-4:0.25:4;
>> [x,y]=meshgrid(x,y);
>> z=2^(-1.5*sqrt(x^2+y^2))*cos(0.5*y)*sin(x);
>> surfl(x,y,z)
>> x=-4:0.25:4;
151
>> y=-4:0.25:4;
>> [x,y]=meshgrid(x,y);
>> z=2^(-1.5*sqrt(x^2+y^2))*cos(0.5*y)*sin(x);
>> waterfall(x,y,z)
152
(i) 3-D Contour plot
>> x=-4:0.25:4;
>> y=-4:0.25:4;
>> [x,y]=meshgrid(x,y);
>> z=2^(-1.5*sqrt(x^2+y^2))*cos(0.5*y)*sin(x);
>> contour(x,y,z,15)
153
>> %(i) 3-D Contour plot
>> x=-4:0.25:4;
>> y=-4:0.25:4;
>> [x,y]=meshgrid(x,y);
>> z=2^(-1.5*sqrt(x^2+y^2))*cos(0.5*y)*sin(x);
>> contour3(x,y,z,15)
Result:-
The following plots were drawn Mesh plot, Surface plot, Mesh curtain plot, Mesh and contour plot,
Surface and contour plot, Surface plot with lighting, Water fall plot, 2-D contour plot and 3-D contour
plot
154