1)
Line 1: clc command clears all data in the command window.
Line 2: clears the system memory, removes the data from workspace.
Line 3: closes all the files.
Line 4: leaves the line blank.
Line 5: forms variable N and fills it with the data from the file “note.txt”.
Line 6: forms variable E and fills it with the data from the file “elem.txt”.
Line 7: leaves the line blank.
Line 8: returns NN variable, which is the length of the largest array dimension in N.
Line 9: returns NE variable, which the length of the largest array dimension in E.
Line 10: leaves the line blank.
Line 11: assgins the value 2.1∙106 to the variable E0.
Line 12: assgins the value 22.8 to the variable A0.
Line 13: assgins the value 935 to the variable I0.
Line 14: leaves the line blank.
Line 15: hold on command keeps the same axis when the new lines are added to the plot, and retains the old plot.
Line 16: cycle start, the next lines (until end statement) are repeated for i = 1 to i = NE times
Line 17: plots the function with the set coordinates, line with black color and linewidth 2.
Line 18: adds text description at the point with coordinates x = N(E(i,1),1+(E(i,2),1))/2 and y = N(E(i,1),2+(E(I,2),2))/2, text printed is the value of i, the font color is blue, size 12.
Line 19: the line ends the cycle started at Line 16.
Line 20: leaves the line blank.
Line 21: cycle start, the next lines (until end statement) are repeated for i = 1 to i = NN times.
Line 22: checks the value of i, and if i < 3, then Line 23 is performed;
Line 23: plots the function with coordinates N(i,1), N(i,2) with solid black line with red square markers of 12 size.
Line 24: else operator indicates the actions for i > = 3.
Line 25: plots the function with coordinates N(i,1), N(i,2) with solid black line with black circle markers of 8 size.
Line 26: the line ends the ‘if’ block, started at Line 22.
Line 27: adds text description at the point with coordinates x = N(i,1), y = N(i,2), text printed is the value of i, the font color is green, size 12.
Line 28: the line ends the cycle started at Line 21.
Line 29: leaves the line blank.
Line 30: assigns a zeros matrix named F with 1 row and 3 * NN columns.
Line 31: assigns FN array with values 11, 12, 17, 18, 23, 24.
Line 32: assigns -20 value to the 3*FN-2 value of the F-array.
Line 33: assigns -10 value to the 3*FN-1 value of the F-array.
Line 34: leaves the line blank.
Line 35: assigns 20 value to the scale variable.
Line 36: cycle start, the next lines (until end statement) are repeated for i = 1 to i = FN times.
Line 37: plots the function with coordinates N(FN(i),1), N(FN(i),2) with solid blue line with blue star markers of 10 size.
Line 38: plots the function with the set coordinates with solid blue line with blue star markers of 10 size.
Line 39: leaves the line blank.
Line 40: assigns the ang variable
Line 41: assigns xp variable the value scale * cos(ang).
Line 42: assigns yp variable the value scale * sin(ang).
Line 43: plots the function with coordinates N(FN(i),1) + xp, N(FN(i),2) + yp with dashed red line, width 2, with red right triangle markers.
Line 44: the line ends the cycle started at Line 36.
Line 45: leaves the line blank.
Line 46: adds a text name “A schematic of the power tower” with size 12 to the plot.
Line 47: sets the axis with the fontsize 12.
Line 48: arranges the axis so that all the data were fit to the plot. As a result, the data are plotted to the edges of the plot.
Line 49: printing the data into the TIFF image with 400 dpi resolution and name “frame.tiff”
Line 50: leaves the line blank.
Line 51: assigns a zeros matrix named K with 3* NN row and 3 * NN columns.
Line 52: cycle start, the next lines (until end statement) are repeated for i = 1 to i = NE times.
Line 53: calculates the value L by the specified formula.
Line 54: calculates the value lx by the specified formula.
Line 55: calculates the value ly by the specified formula.
Line 56: calculates the value a by the specified formula.
Line 57: calculates the value b by the specified formula.
Line 58: calculates the value c by the specified formula.
Line 59: calculates the value d by the specified formula.
Line 60: leaves the line blank.
Lines 61-66: assign the array Ke with 6 columns and 6 rows, set the values for the Ke.
Line 67: leaves the line blank.
Lines 68-73: assign the array Ke with 6 columns and 6 rows, set the values for the T.
Line 74: leaves the line blank.
Line 75: calculates the value Ke by the specified formula.
Line 76: assigns array i.
Line 77: calculates array j value.
Line 78: calculates dof value.
Line 79: calculates K(dof,dof) value for the dof column and dof row of the K array.
Line 80: the line ends the cycle started at Line 52.
Line 81: leaves the line blank.
Line 82: assigns an array with 6 columns and 1 row with the specified values;
Line 83: assigns alldofs with 1 row and 3*NN columns.
Line 84: sets difference between the arrays alldofs and fixeddofs, returns the values of alldofs that are not in fixeddofs.
Line 85: calculates U(freedofs, :) array with all the elements at freedofs dimension. U(freedofs, :) values are obtained by the formula K(freedofs, freedofs)/ F(freedofs, :)
Line 86: assigns the array U(fixeddofs, :) the value 0.
Line 87: leaves the line blank.
Line 88: creates a figure window;
Line 89: keeps the same axis when the new lines are added to the plot, and retains the old plot.
Line 90: calculates BD value by
Line 91: leaves the line blank.
Line 92: cycle start, the next lines (until end statement) are repeated for i = 1 to i = NE times.
Line 93: plots the function with the set coordinates, solid black color and linewidth 2.
Line 94: plots the function with the set coordinates, dash blue color and linewidth 2.
Line 95: the line ends the cycle started at Line 92.
Line 96: leaves the line blank.
Line 97: adds title “The deformation magnified __ times” to the figure; ___ represents the number of times obtained from the conversion of scale to string variable. The title fontsize is 12.
Line 98: turns off the equal size of the axis; the axis size is greater than the plot.
Line 99: sets the axis with the fontsize 12.
Line 100: prints the graph into U-frame.TIFF file with resolution 400 dpi.
2)
The fram problem includes only horyzontal or vertical frame, and while for the truss there are both horyzontal and vertival axes. Each point of the truss has the axial force and does not undergo the bending formation. The mathlab procedure for truss is more complicated.
Starting from the line 78, the program has been modified to include the vertical elements and nodes. Therefore, the proceduder of calculation of the forces for the horizontal and vertival elements is more complicated.