Skip to main content

Featured Post

NEMA 17 vs NEMA 23: Torque, Speed, and When to Upgrade

When building a CNC router or upgrading a 3D printer, the first question is usually: "Is NEMA 17 enough, or do I need NEMA 23?" Most beginners look at the Holding Torque and stop there. This is a mistake. A NEMA 23 motor isn't just "stronger"—it is physically different in ways that affect your speed, your driver choice, and your machine's ability to avoid missed steps. If you choose a NEMA 17 for a heavy gantry, it is far more likely to overheat or lose steps under cutting load. If you choose NEMA 23 for a fast 3D printer, it might actually run slower than the smaller motor. This guide explains the engineering limits of each frame size. Table of Contents 1. Physical Difference (The Frame Size) 2. Torque & Speed (The Inductance Trap) 3. Driver Compatibility 4. Selection Summary Advertisement 1. Physical Difference (The Frame Size) "NEMA" is just a standard for ...
Disclosure: As an Amazon Associate, I earn from qualifying purchases.

Solving System of Equations using Gauss Elimination Method (Part 1)

The Backbone of Engineering Simulation

In mechanical engineering, solving a system of linear equations is perhaps the most fundamental calculation we perform. Whether you are running a Finite Element Analysis (FEA) to check stress concentrations or a Computational Fluid Dynamics (CFD) simulation, the computer is ultimately solving a massive system of equations in the form of [A]{x} = {B}.


The Gauss Elimination Method is a classic algorithm used to solve these systems. Unlike Cramer's Rule, which is inefficient for large matrices, Gauss Elimination scales well for complex engineering problems.

Advertisement

Step 1: Setting up the Matrix

To solve a system of equations in Excel, we first organize our coefficients into a matrix format.

As shown in the figure below, the coefficients of the variables (x, y, z) form the [A] Matrix, while the constants on the right side of the equal sign form the {B} Vector.

Figure 1: Initial setup of the Coefficient Matrix [A], Constant Vector {B}, and the resulting Solution Vector.

Step 2: Forward Elimination and Back Substitution

The algorithm works in two stages:

  1. Forward Elimination: We manipulate the rows to convert the [A] matrix into an Upper Triangular Matrix. This means all elements below the main diagonal become zero.
  2. Back Substitution: Once the last variable is isolated, we solve for it and substitute the value back up the chain to find the remaining variables.
Flowchart showing Matrix Transformation to Upper Triangular form
Figure 2: The logic flow: transform to upper triangular, then back-solve.

The result of this process is shown in the figure above. Notice how the calculation identifies the precise values for X1, X2, and X3 that satisfy all equations simultaneously.

Excel VBA Code Implementation

While you can perform these steps manually in Excel cells, using VBA (Visual Basic for Applications) is much more powerful for repetitive design tasks.

Below is a custom function you can use. To install it:

  1. Press Alt + F11 to open the VBA Editor.
  2. Go to Insert > Module.
  3. Paste the code below.
Option Explicit

' Function to solve linear equations Ax=B using Gauss Elimination
Function SolveLinearSystem(coeffMatrix As Range, constMatrix As Range) As Variant
    Dim n As Integer
    Dim i As Integer, j As Integer, k As Integer
    Dim factor As Double
    Dim a() As Double
    Dim b() As Double
    Dim x() As Double
    Dim sum As Double
    
    n = coeffMatrix.Rows.Count
    
    ' Resize arrays
    ReDim a(1 To n, 1 To n)
    ReDim b(1 To n)
    ReDim x(1 To n)
    
    ' Read data from Excel ranges to arrays
    For i = 1 To n
        For j = 1 To n
            a(i, j) = coeffMatrix.Cells(i, j).Value
        Next j
        b(i) = constMatrix.Cells(i, 1).Value
    Next i
    
    ' --- Forward Elimination ---
    For k = 1 To n - 1
        For i = k + 1 To n
            If a(k, k) = 0 Then Debug.Print "Error: Pivot is zero!"
            factor = a(i, k) / a(k, k)
            For j = k To n
                a(i, j) = a(i, j) - factor * a(k, j)
            Next j
            b(i) = b(i) - factor * b(k)
        Next i
    Next k
    
    ' --- Back Substitution ---
    x(n) = b(n) / a(n, n)
    For i = n - 1 To 1 Step -1
        sum = 0
        For j = i + 1 To n
            sum = sum + a(i, j) * x(j)
        Next j
        x(i) = (b(i) - sum) / a(i, i)
    Next i
    
    ' Return result as a vertical array
    SolveLinearSystem = Application.WorksheetFunction.Transpose(x)
End Function

You can now use this function in any cell by typing =SolveLinearSystem(A_Range, B_Range).

Advertisement

Next Part

Continue to the advanced application in the next post:
Solving System of Equations using Gauss Elimination Method (Part 2)

References

Comments

Popular posts from this blog

Dowel Pins & Locating Pins: The Basics of Fixture Design

Figure 1: A typical fixture setup. Notice how dowel pins (silver) provide precise location, while bolts (not shown here) provide the clamping force. In the world of Precision Engineering , the difference between a high-quality product and a scrap part often comes down to microns. While bolts hold parts together, they are terrible at positioning them. This is where Dowel Pins and Locating Pins become essential components in industrial tooling . Advertisement What is a Dowel Pin? Dowel pins are precision-ground fasteners used to secure the relative position of two parts. They are typically machined to extremely tight tolerances (often within 0.0001 inches) and are available in materials like: Hardened Steel: For high-wear applications in CNC fixtures . Stainless Steel: For corrosion resistance in medical or food processing machinery. Plastic (Thermoplastic): For lightweight, non-conductive, low-load alignment. The ...

Hoeken's Linkage: Kinematics and Walking Robot Design

Figure 1: Animated simulation of the Hoeken’s Linkage showing the characteristic "tear-drop" coupler curve. 🚀 New Design Guide Available Don't just read about it—build it. Check out our new tutorial: How to Design a Hoeken’s Linkage in Excel (with Free VBA Simulator) » Introduction to the Hoekens Linkage The Hoekens linkage is a specialized four-bar mechanism designed to convert rotational motion into an approximate straight-line motion. While it serves a similar purpose to other straight-line generators, its unique coupler curve—a "tear-drop" shape—makes it exceptionally useful for intermittent motion and walking machines. One of the most fascinating aspects of kinematic theory is the concept of "Cognates." The Hoekens linkage is actually a cognate linkage of the Chebyshev Straight-line Mechanism . This means that while the physical structure and link lengths differ, they can generate...

Watt Straight-Line Linkage: Analysis and Automotive Uses

Figure 1: Watt's linkage example geometry and path generation. Introduction to Watt's Linkage The Watt's linkage (also known as the parallel motion linkage) is a cornerstone in the history of mechanical engineering. It is a type of four-bar linkage originally invented by James Watt in the late 18th century to solve a critical problem in steam engine design: constraining the piston rod to move in a straight line without using high-friction guideways. Before this invention, engines used chains to connect the piston to the beam, which meant they could only pull, not push. Watt's rigid linkage allowed for double-acting engines (pushing and pulling), doubling the power output. He was immensely proud of this kinematic solution, describing it in a 1784 letter to his partner Matthew Boulton: "I have got a glimpse of a method of causing a piston rod to move up and down perpendicularly by only fixing it to a piece of iron u...