Written By Dave Martin
• Math Tips
• 12/16/2019
• Read Time : 5 min. In a previous article, we compared traditional spreadsheets to PTC Mathcad. We showed that for engineering calculations, a tool designed to support variables, functions, programs, and real-math notation makes a better choice for product development than a tool used for accounting.

## Using PTC Mathcad with Excel

PTC Mathcad and Microsoft Excel are not mutually exclusive for product development; you can use both. You might have legacy spreadsheets with historical data, or you might have data stored in Excel, text, or comma-separated value (CSV) formats that you want to use.
For example, I’ve had Excel files for power spectral density functions for dynamic analyses, strain gauge data from structural testing, and airfoil (wing) profiles. Ideally, I would want to recreate them in PTC Mathcad, but that’s not always feasible or possible. Fortunately, I can leverage the existing spreadsheets and integrate them into my PTC Mathcad worksheets.

PTC Mathcad has built-in functions that help to import Excel data. You can use the READEXCEL function to specify the file and cells to import. Alternatively, the READEXCEL button on the Input / Output tab opens a user-friendly dialog box that will help you browse to the Excel file and specify which rows and columns to import.

By assigning the READEXCEL function to a variable, it becomes a matrix that you can use in vector and matrix functions and programs.
Since this function is part of a live worksheet, when you update the Excel spreadsheet, your matrices and calculations update when you recalculate the worksheet.

You can also embed an Excel component in your PTC Mathcad worksheet. The Excel component is a real Excel worksheet, and double clicking it opens your data inside Microsoft Excel.

The Excel component has Input and Output sections, so you can pass variables and values into and out of specified cells in the worksheet. Here is the lift calculation from the previous article embedded in my PTC Mathcad worksheet: A traditional spreadsheet used to calculate aircraft lift. Data can be passed between PTC Mathcad as input and output.

This is a great way of leveraging pre-existing design information without reinventing the wheel.
If you are exchanging data with people in Excel format, you can use the WRITEEXCEL function to export a matrix, or part of a matrix, to an Excel spreadsheet.

We perform engineering calculations to design engineering models. Ideally, we want our engineering calculations to drive our CAD designs directly. There are two different ways to do this: either we can embed our PTC Mathcad worksheets into a Creo Parametric part or assembly, or we can connect our Creo models to a worksheet.

In the first method, we embed either a pre-existing or a new PTC Mathcad worksheet in a model using the Applications tab. In the second method, we use the Prime Analysis feature that calls a PTC Mathcad worksheet.

There are two essential differences between the methods: when you embed the worksheet and connect PTC Mathcad variables to parameters in the model, you can push the latest worksheet calculations to the model. Also, no separate file exists for the PTC Mathcad worksheet. When you connect the worksheet via the Prime Analysis feature, you can have the calculations re-performed on every regeneration if desired, and you have a separate worksheet file. Example of a PTC Mathcad worksheet that receives values from Creo Parametric and returns calculations.

Both methods send values from Creo Parametric to the PTC Mathcad worksheet, perform calculations in the worksheet, and then return other values back. These values then drive model dimensions.

Design intent governs our modeling decisions in Creo Parametric, and embedding or connecting PTC Mathcad worksheets captures the design intent of our engineering calculations. We can ensure that our product geometry updates in ways that we plan and expect, based on real engineering knowledge. Tags:
• Math Tips