Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a Mircrosoft Excel VBA code to solve the deflection in the beam numericall

ID: 3820766 • Letter: W

Question

Write a Mircrosoft Excel VBA code to solve the deflection in the beam numerically. The beam is supported at both ends (deflection zero at both ends)

Use delx= 24 inches (11nodes)

El d2y/dx2= M(x), where E = 29000 ksi, I = 204 in4 , w = 0.167 kip/inch, and L = 240 inches

For uniform loading, M(x) = w/2 (Lx-x2)

***Use the following Code and debug it. (fill in the question marks)

Private Sub CommandButton1_Click()
Dim a(20, 20) As Double, delx As Double, EI As Double, x As Double, i As Integer, j As Integer
Dim b(20) As Double, y(20) As Double, yanal(20), n As Integer, w As Double, L As Double
'Define values of n, delx, L, EI, w

'Initialize the A matrix
For i = 1 To n
For j = 1 To n
a(i, j) = 0#
Next j
Next i

'Assemble A matrix
'For i = ???
'a(???) = -2
a(i, i + 1) = 1
'???
Next i

'Boundary conditions for A matrix
'a(1, 1) = ???
'a(???) = 1#
'set appropriate b values b(1) and b(n) 'deflection at the boundary

'assemble B matrix entries
For i = 2 To 10
'x = ???
' b(i) = ??? * (L * x - x ^ 2) /???
Next i

'Use this to check your A matrix

'For i = 1 To n
'For j = 1 To n
'Cells(i, j) = A(i, j)
'Next j
'Next i

'Use this to check your B matrix
'For i = 1 To n
'Cells(i, 1) = B(i)
'Next i

'Solve the matrix problem and output y values

'Compare with analytical solution to check results
For i = 1 To n
'x = ???
'yanal(i) = ((w * L * x ^ 3 / 12) - ???
Cells(i, 2) = yanal(i)
Next i

End Sub

Explanation / Answer

Private Sub CommandButton1_Click()
Dim a(20, 20) As Double, delx As Double, EI As Double, x As Double, i As Integer, j As Integer
Dim b(20) As Double, y(20) As Double, yanal(20), n As Integer, w As Double, L As Double
'Define values of n, delx, L, EI, w

'Initialize the A matrix
For i = 1 To n
For j = 1 To n
a(i, j) = 0#
Next j
Next i

'Assemble A matrix
'For i = 1 To n ???
'a(i,i???) = -2
a(i, i + 1) = 1
'???
Next i

'Boundary conditions for A matrix
'a(1, 1) = -2#???
'a(n,n???) = 1#
'set appropriate b values b(1) and b(n) 'deflection at the boundary

'assemble B matrix entries
For i = 2 To 10
'x = 24 ???
' b(i) = w ??? * (L * x - x ^ 2) /2 ???
Next i

'Use this to check your A matrix

'For i = 1 To n
'For j = 1 To n
'Cells(i, j) = A(i, j)
'Next j
'Next i

'Use this to check your B matrix
'For i = 1 To n
'Cells(i, 1) = B(i)
'Next i

'Solve the matrix problem and output y values

'Compare with analytical solution to check results
For i = 1 To n
'x = 24 ???
'yanal(i) = ((w * L * x ^ 3 / 12) - (w * x ^ 4 / 24)???
Cells(i, 2) = yanal(i)
Next i

End Sub

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote