Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X
Is there any way to copy a column of data from@ MS Excel and paste it into a Mathcad matrix?
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
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
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!
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.
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".
Example for a table in Excel:
It's silly that Prime doesn't allow to copy-paste such a table to a matrix definition instantly,
like Mathcad does:
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:
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:
Now you can read it into Prime with:
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.
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.