Tutorial: Moving to Mathcad from Excel

Moving to Mathcad from Excel

There are many reasons to move to Mathcad from Excel as an engineering calculation environment. These include, to name a few:

  • clarity of notation (readability)
  • clarity of dependencies (verification)
  • unit analysis (error checking)
  • breadth of calculation tools (completeness)
  • engineering-appropriate graphs, image analysis, matrix analysis, and data support

But what are the challenges in making this transition? The challenge has to do with a preference for vector/data-driven calculations versus functional calculations. Both styles of calculation are possible in Mathcad, but our documentation and examples tend to prefer functional notation for its reusability and summarizing characteristics. Many Excel users are surprised or stymied by this difference in usage, or they are unable to gracefully transition from Excel cells to Mathcad vector and matrix notation. The vector style notation is closest to what Excel does in the cell format, but it's not always the most efficient way to pose a problem in Mathcad. Here is an example. Consider the problem of a cantilevered beam with a uniform force applied across it as shown in Figure 1.

The typical Excel sheet contains some cells near the top with input values for the problem such as length of the beam, the distributed force along the beam, and the modulus and moment of the beam. What follows is a set of columns representing various positions along the beam, and the shear, moment, and deflection at each of those positions, each calculated with a formula that looks something like the formula shown in Figure 2.

Now aside from the fact that it's a little hard to know what the values represented by B3, E3, E4, and A7 represent, notice that Excel requires you to solve the problem in "vector format." A vector of positions, stored as sequential cells, feeds other vectors, one cell (or element) at a time. If you desire a table of data for the problem, then this can be a useful representation. To replicate that style of problem solving in Mathcad begin by defining the variables as shown in Figure 3.

Due to the weight of the beam itself, there is a uniformly distributed load across the beam, causing reaction, shear, and moment. Assume that you'd like to see the calculations at 11 positions along the beam. Set up an index for the vectors, using a range defined as i as shown in Figure 4.

Evaluate the variables as shown in Figure 5. You now have a set of tables similar to what you might see in Excel. But there are some important differences. Excel uses as many cell entries as you fill with explicit values for position. Mathcad requires that you say how many values you wish to calculate, then produces that number of cells in its vector display. The range i contains integers, which are used as indices to iterate over values in the vectors x, V, M, and Δ y.

You can make this calculation just a little more flexible by assigning a number of points under a separate name as shown in Figure 6. Doing so changes the setup to use N as the end of the range, as a divisor when creating the vector of x values along the length of the beam, L. There are now 15 points in x, since the origin for vectors and matrix indexing is 0, although you can change this to 1 if you prefer.

Order matters

By setting up the calculation in this way, you can change the value of N to anything you like, and your tables below the definition update to show the appropriate spacing and number of entries. But notice that if I redefine these values below the original definitions, I'll have to make copies of the other dependent things to get them to pick up the new values. Unlike Excel, I care where my definitions are, because everything is in top-down-left-right order. This is the next shift in thinking that Excel users must adopt: order matters, and redefinition of the same name matters. Look at this series of definitions shown in Figure 7. Notice that after the first definition, x is no longer a vector of values, as it was before.. It's a scalar value now, and if I evaluate it, or more importantly use it in another expression, it's going to use the most recent top-down-left-right definition. Unlike Excel, where cell A3 is always A3 until I type a new value in it, using names comes with the responsibility to define them in order, and not to reuse them until you're really ready for a new value.

Functions and flexibility

Fundamentally, the vector calculation shown isn't that different from an Excel-style calculation, with the important exceptions that columns now have names, they carry and convert appropriate units, and can be usefully parameterized with controls such as the number of points, to generate more or less accuracy in the table or in a graph. But Mathcad gives you an important advantage when doing calculations like these, and that is the ability to define your own reusable functions. When Excel calculations are simply replicated as discrete table points, they lose some of the utility of a full featured engineering calculation environment. Consider the shear, moment, and displacement calculations encoded as functions shown in Figure 8.

Notationally, these look very much like the formulas from a book. They even cast the parameters of the beam as additional arguments so that they can be copied to other documents or use different values within the same document just by calling them with other variable names or with specific values in place. For example review the deflection calculations shown in Figure 9.

As functions, you can integrate over them, differentiate over them, optimize on them, reuse them in other scenarios, and call them with a variety of inputs as shown in the moment calculation in Figure 10.

The functions make no assumptions about the discreteness of the problem and can be used with any granularity of input. For example, now you can make a range of x's, as shown in Figure 11, rather than the integer indexes you defined earlier, and use it to plot the various curves represented the deflection of the beam as shown in Figures 12, 13, and 14.

Learn more with other tutorials...

Creating Better Homework Papers with Mathcad
Matrices in Algebra 1: Mathcad 15.0 Illustrates the Solutions Clearly
  • Matrices in Algebra 1: Mathcad 15.0 Illustrates the Solutions Clearly

  • |
  • 5544 Views
  • |
  • Intermediate Level
  • |
  • Matrices are challenging, but they are really important in applied mathematics – they are a critical STEM topic. Engineers and scientists use matrices to solve challenging problems in many, many dimensions. ... (Show more)
Solving an Ordinary Differential Equation Using Mathcad
Plug in to unlimited learning! Learn more

Unlimited Classroom Subscription

This new offer from PTC University is a cost-efficient way to access an unlimited number of training classes and thus promotes the importance of skill improvement within your organization.
Download the datasheet >>   
Replay video? Resume video