Plotting Complex Data in Mathcad

Plotting Complex Data in Mathcad

Watch out for complex numbers in your data, which can not be plotted in Mathcad. Imaginary parts in your numbers leads to either incomplete graphs or errors instead of plots. To work with complex numbers, you can plot the real and imaginary parts of your numbers separately, or reframe your data to calculate only the real part before plotting.

2D Plots

Mathcad 2D plots skip numbers that have an imaginary part. Use the data shown in Figure 1 as an example.

View the plotted data in Figure 2. Notice there is a break in the line and the point at x = 3 is missing.

You can separate the real and imaginary parts before plotting using Mathcad's Re (returns the real part of a complex number) and Im (returns the imaginary part of a complex number) functions as shown in Figure 3.

Alternately, you can make the numbers real by taking the magnitude. For example, plotting the output of an FFT often produces an unexpected plot since most of the values have a complex part As shown in Figure 4. Note the use of the vectorize operator [Ctrl] [-] to apply the absolute value operator on an element-by-element basis.

Note the complex data shown in Figure 5, and the plotted data in Figure 6. If all data is complex, you see an error rather than a plot.

3D Plots

Mathcad 3D plots ignore the imaginary part of any data and plot only the real part. So again, the two components must be separated for complex-valued inputs. Input a complex function as shown in Figure 7.

The real part of the input is shown in Figure 8 and the imaginary part is shown in Figure 9.

The matrix input to plotting routines is shown in Figure 10.

Plot both the real and imaginary parts as contours as shown in Figures 11 and 12.

Learn more with other tutorials...

Solving an Ordinary Differential Equation Using Mathcad
Electronic Curriculum Unit Development with Mathcad Prime and Microsoft OneNote
Mathcad: Iterate a Parameter in a Minimize or Maximize Solve Block
Our tutorials are moving... Continue learning here!

A new home for PTC tutorials

Our free tutorials have a new home - and they are no longer alone. We have created the new PTC Learning Connector Portal to provide a one-stop shop for learning and support for PTC software. Access free tutorials, support content and eLearning via one single site.
Visit now   
Replay video? Resume video