Importing data from the clipboard MathCad Help

In some cases, you may have data stored in a spreadsheet or another application, but you don’t want to import the data as a file into Mathcad. An alternative to importing a file is to copy the data to the clipboard and paste it into Mathcad. To do so

• Select the data in the other application and copy it to the clipboard. In most applications, you do this by choosing Copy from the Edit menu.
• Open the Mathcad worksheet in which you want the data to be used.
• In your Mathcad worksheet, type a variable definition such as m: =
• Click in the placeholder to the right of the := and choose Paste from the Edit menu. A matrix containing the data you copied will appear.

When you click outside the component, the data you copied will appear in a scrolling table and are assigned as an array to the Mathcad variable you specified. You can manipulate the array however you’d like using Mathcad’s built-in functions and operators.

Note that if you paste the copied data into a blank spot of a Mathcad worksheet instead of into a placeholder, you’ll also see a matrix containing the data you selected.

When you double-click on the table, you can edit the values in it. You’ll see scroll bars which let you scroll through the table. You’ll also see handles along the sides of the component region. To resize the table, move the cursor to one of these handles so that it changes to a double-headed arrow, press and hold down the mouse button and drag the cursor in the direction you want the table’s dimensions to change.

Entering data manually

It is usually most convenient to have your data stored somewhere on your computer so that you can import the data into Mathcad, either as a file or from the clipboard. However, when you don’t have a lot of data and it is not already stored in another application, you can enter your data directly into Mathcad. To do so, create an input table using the Input Table component:

• In the placeholder that appears, enter the name of the Mathcad variable to which this data will be assigned,
• Double-click on the component and enter data into the cells, Each row must have the same number of data values, If you do not enter a number into a cell, Mathcad inserts 0 into the celL

Figure 19-2 shows two input tables, Notice that when you create an input table, you’re actually assigning elements to an array that has the name of the variable you entered into the placeholder. Once you’ve created an array using an input table, you can manipulate the array using Mathcad’s built-in functions and operators. Note that if you have a set of X and Y data values, you will probably find it easiest to create one input table for the X’s and one for the Y’s

Another way to create an input table is to use a range variables as subscript for another Mathcad variable name. See the section “Entering a table of numbers” in for more information.

Exporting data

Once you’ve used Mathcad to perform calculations, you can export the results either to a data file or to the clipboard for pasting into another application. The File Read! Write component and the Output Table component allow you to do this. For a general discussion of components see “Introduction to components” on page 422. You may use any Mathcad variable you have defined in your worksheet as an input variable to the component. The component either sends the data to a data file or lets you copy it to the clipboard.

Exporting to a data file

Mathcad allows you to export the values stored in a Mathcad variable to a variety of file formats, such as the following:

• Excel (*.xls)
• MATLAB (* .mat) (professional edition only)
• Lotus 1-2-3 (*.wk*)
• ASCn editors (*.dat, *.csv, *.pm, *.txt)

When you want to export data to a data file, you should first decide whether you want the data to update automatically in the data file when it changes in Mathcad. If your results are likely to change in Mathcad, and you want to export the new results to a data file whenever the worksheet is calculated, you can export the data and establish a connection between the data file and your Mathcad worksheet. To do so, use the File Read/Write component. If you do not want the data file to change if the results in Mathcad change later on, you can export without establishing a connection between Mathcad and the data file. To do so, use the Output Table component.

Exporting to a connected data file

To export values stored in a Mathcad array or scalar variable to a data file and establish a connection between your Mathcad worksheet and the data file:

• Click in a blank spot in your worksheet.
• Choose Component from the Insert menu.
• Select File Read/Write from the list and click “Next.”

This launches the first part of the File Read or Write Wizard in which you can specify whether the component will read from a data file or write to one. Choose “Write to a data source” and press “Next” to go to the second page of the Wizard:

•From the File Format drop-down list in this Wizard, choose the type of data file you want to write.
• Type the path to the data file you want to write or click the “Browse” button to locate it.

In the placeholder that appears, enter the name of the Mathcad variable containing the data which will be written to the data file. When you click outside the component, all the values in the input variable will be written to the file name you specified. Each time you calculate the worksheet, the data file is rewritten. See Figure 19-3 for an example.

Using the File Read/Write component to export data from

Using the File Read/Write component to export data from

To change the name of the data file being created to or to change the type of file being created:

• Click once on the component to select it.
• Click with the right mouse button on the component so that you see the context menu for the component (see example on page 424).
• Select Choose File. You will see the Write to File dialog box.
• In the “Files of type” text box, choose the type of file you’d like to create. Use the dialog box to browse to the folder in which the data file will be created and click “Open.”

Exporting once to a data file

To export data without establishing a connection between Mathcad and the data file, use the Output Table component:

• Click in a blank spot in your worksheet.
• Choose Component from the Insert menu.
• Select Output Table from the list and click “Next.” The Output Table component will be inserted into your worksheet.
• In the placeholder that appears, enter the name of the Mathcad variable containing the data to be exported.
• Click on the component with the right mouse button so that you see the context menu for the component (see example on page 424).
• Choose Export. You will see the Write to File dialog box.
• In the “Files of type” text box, select the format of the file you’d like to create. Use the dialog box to browse to the folder in which the data file will be created and enter the name of the data file you wish to create. Then click “Open.”

Changing the format of the numbers in the table

The numbers displayed in the Output Table component will display using a default format specific to the component. Unlike most other values displayed in Mathcad, the values in the Output Table component are not affected by the settings in the Number Format dialog box. To change the way the numbers are displayed in the component:

• Click once on the component to select it.
• Click on the component with the right mouse button so that you see the context menu.
• Choose Properties from the context menu.
• Go to the Display tab, which looks like this

Changing the format of the numbers in the table

Changing the format of the numbers in the table

The settings on the Display tab are as follows:

Displayed Precision: Choose or type an integer n. Determines the number of values to the right of the decimal place.

Exponential Threshold: Choose or type an integer n. Values smaller than lO-n or greater than Ion are displayed in exponential notation.

Zero Tolerance: Choose or type an integer n. Values smaller than lo-n are displayed as zero.

Show index labels: Click this box to display the row and column numbers associated with the values in the table.

Keep in mind that these settings only affect the display of numbers in the Output Table component. They do not affect the value written to a data file if you choose Export from the context menu of the Output Table component.

Posted on November 24, 2015 in Data Management

Share the Story

Back to Top
Share This