cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

The community will undergo maintenance on October 16th at 10:00 PM PDT and will be unavailable for up to one hour.

Is there any way to copy a column of data from MS Excel and paste it into a Mathcad matrix?

gatlas-2
1-Newbie

Is there any way to copy a column of data from MS Excel and paste it into a Mathcad matrix?

Is there any way to copy a column of data from@ MS Excel and paste it into a Mathcad matrix?

11 REPLIES 11
StuartBruff
23-Emerald III
(To:gatlas-2)

Glen Atlas wrote:

Is there any way to copy a column of data from@ MS Excel and paste it into a Mathcad matrix?

What do you mean by "paste it into a Mathcad matrix"?  Do you mean "insert it into an existing matrix"? Or "create a new matrix"? Or ..?

I haven't got Excel, but using Microsoft's Excel Reader App in Win 10, I just copied a column from an xlsx sheet and pasted it straight into Mathcad 15 as a matrix.  Unfortunately, I don't seem to be able to do that in Prime 3.1.

Stuart

StuartBruff
23-Emerald III
(To:StuartBruff)

Oh, in case you didn't know, you could also use the READEXCEL function or Excel component to read data straight from a worksheet.

Stuart

Werner_E
25-Diamond I
(To:gatlas-2)

Glen Atlas wrote:

Is there any way to copy a column of data from@ MS Excel and paste it into a Mathcad matrix?

Yes, its easy.

Copy the column(s) in Excel via Ctrl-C.

In Mathcad simply type M: and then, when the cursor is in the placeholder after the := insert via Ctrl-V. This will create a Mathcad vector/matrix.

If you meant pasting it as part of an already existing matrix, I guess the answer is no, as you will end up with the whole column(s) being just one element of that matrix.

If you press Ctrl-V without creating a placeholder you insert an Excel-Object in your Mathcad sheet.

BTW, I am talking of real Mathcad (that is version 15 and below) - not about Prime. It doesn't work in Prime that way.

If you simply paste in Prime you get a table, which might be what you want but if you try to paste it after M:= it doesn't work at all. What an improvement.

Of course you can always import your data via Excel component or using READEXCEL.

Thanks. I knew I could copy from excel into Mathcad 15. I thought I could do it with Prime... No big deal as I prefer Mathcad 15 anyway.

Glen Atlas wrote:

Thanks. I knew I could copy from excel into Mathcad 15. I thought I could do it with Prime... No big deal as I prefer Mathcad 15 anyway.

Copy from Excel into Mathcad 15, save the sheet and convert it into Prime!

JeffH1
15-Moonstone
(To:gatlas-2)

If you paste the column/matrix at a blank location in Mathcad Prime, it creates a data table instead of a matrix.  I actually think these are pretty cool.  You just go across the top of the table and fill in the variable names and units for each column and Prime creates a vector for each column with the units you specify.

To do the same thing in v15, you have to past into the matrix, extract each column of the matrix into a separate vector, and apply the right units to each vector.

Prime tables make this a snap, AND the table and header rows provide clear, crisp documentation of the data being imported.

MikeArmstrong
5-Regular Member
(To:gatlas-2)

You could just call the data from Excel into Mathcad and then select the column.

You can insert an EXCEL component into Prime, then copy and paste from EXCEL to {EXCEL in Prime}, you can then define an output variable that addresses the range of the EXCEL sheet and viola--a vector or matrix.   S o o o much easier than copy/paste!

Sorry @Fred_Kohlhepp , not s o o o easy.  A cut and paste into a plain matrix would be the easiest.  Cut and pasting between apps is very old school but simply not yet implemented in Prime--they are not on the ball with so many simple concepts in Prime (sadly even today in Prime 8).  Almost any 'table-like' structures in other apps can accept pasting of tab-delimited tables (Excel, Word, Smartsheets (online spreadsheets), AutoCAD, Google Docs, at least these are the ones I have used).  

 

Having an excel component only makes things worse (not as elegant) and I have to provide output definitions.  I don't have Mathcad 15 to take the longer route as I can't afford both licenses at once.  And I can't paste it as a table because I need it as a 2D matrix and not multiple column vectors.

 

In my case I have a large 34x17 matrix that I want to enter into Prime so that you can see it is stand alone matrix.  I cannot link it to a file because I want to distribute it as a stand-alone calculation sheet.  It also has mixed data of strings, numbers and empty elements (NAN's). 

 

Right now I use a keypress macro to 'type' the data into the Mathcad matrix.  It is still not superior to the computer industry standard of "cut and paste".

LucMeekes
23-Emerald III
(To:SPauliszyn)

Example for a table in Excel:

LucMeekes_2-1656058630568.png

It's silly that Prime doesn't allow to copy-paste such a table to a matrix definition instantly,

LucMeekes_3-1656058763656.png

like Mathcad does:

LucMeekes_4-1656058806298.png

Copy from Excel to paste in Prime in a blank location results in a table, as Jeff explained. You can convert that table to a matrix by augmenting the table colums. This 'll work fine for a limited amount of table columns:

LucMeekes_0-1656058423527.png

But for a large number of colums it's a bit tedious. There's another way.

Copy the table over from Excel to notepad, and save that text file:

LucMeekes_5-1656058870822.png

Now you can read it into Prime with:

LucMeekes_6-1656058976584.png

Once you have the Matrix in Prime, you can copy it and use it in a definition of a matrix, if you want the worksheet to be self-contained.

 

Success!
Luc

@LucMeekes , That works except the READPRN didn't like my data tab delimited txt file whereas READEXCEL works on the original spreadsheet.  I have mixed numbers, strings and NaN's.  See attached txt file.

 

SPauliszyn_0-1656073425731.png

 

 

It will work for moderate sized matrices.  Only issue with a very large matrix is that I need to drag the lower limit down in order to show all the elements, otherwise Prime only copies the displayed elements.  My computer is reasonably fast but when I start getting past line 100 it starts to lag so much and it takes about 20min to finally see the whole matrix so that I can copy it.  So for a very large matrix like this it is still faster to use a keypress macro.

Announcements

Top Tags