Skip to main content
1-Visitor
February 27, 2012
Solved

Storing array from program in MathCad sheet?

  • February 27, 2012
  • 3 replies
  • 11777 views

I would like to store in the worksheet a nested aray generated by a program in the sheet, to avoid the recalculations which are no longer needed once the data is generated.

I tried to assign the array to a variable using cut and paste but this was flagged by a "Matrix too big message" (The array is 100 x 5).

What would be the way to permanently assign this Array to a variable?

Thank you.

Best answer by LucMeekes

Laurent,

this does work with nested arrays, no problem (that is, in Mathcad 11) to any depth. Just try it out in your version.

Be sure to read the (nested) array in with Mathcad, and do not fumble with the data file outside of mathcad, unless you really know what you're doing.

But for your purpose, storing calculation results and retreiving them back in Mathcad, this should be no problem.

Success!

Luc

3 replies

24-Ruby III
February 27, 2012

Laurent Muller wrote:

...I tried to assign the array to a variable using cut and paste but this was flagged by a "Matrix too big message" (The array is 100 x 5).

What would be the way to permanently assign this Array to a variable?

Thank you.

Try to embed and work with a Excel component in the Mathcad worksheet (in main menu go to "Insert" -> "Component..." -> "Microsoft Excel"):

Pic_1.png

Pic_2.png

1-Visitor
February 27, 2012

Thanks Vlad. It looks like Excel is not very happy with nested Arrays though.

Looks like I will have to "unest" the array, store it, and then "renest" it to feed it to the calcs.

Thanks again for your advice.

12-Amethyst
February 27, 2012

Another way, is to generate the matrix, then copy the matrix, then reassign the matrix by pasting on the RHS.
Then disable the program.

tmp.gif

12-Amethyst
February 27, 2012

Hello Laurent,

how deep is the nesting in your array?

attached is array 100*5 * 8*8 that will copy to b:=

It does struggle if Iincrease 100 to ~120 or 5 to 8 (maybe less), at the higher values just gives "bigmatrix" as the result,

regards

Andy

1-Visitor
February 27, 2012

The array is only one deep (100*5). Good to know you can go deeper!

Wayne's suggestion is exactly what I was atempting and didn't work for me (Matrix too big).

But I see it is working fine with AW's example.....

Am on 2001.....so maybe this is the issue: If I try to expand the Nested Array in 2001, then "Matrix too big" flags up.

I gave it a try in 15, but the solver function that works in 2001 doesn't work in 15. So I have to stick with 2001.

File is attached (sorry for the mess, it is work in progress). The Nested Array is on page 15 (SwTT). But if you are on Mcad 15, chances are it won't execute (no solution found), like it did for me in 15.

I will reduce the size of the array while cleaning the file up (size is only for plot resolution) to cut down recalc time if I cannot assign to a variable.

Thanks for all the help.

12-Amethyst
February 27, 2012

Mathcad makes some assumptions about automatic vectorizations, my guess is that this is what changed from the 2001 version. I suggest you stick with 15.

tmp.gif

23-Emerald IV
February 27, 2012

Laurent,

There's another possibility, apart from storing the result in the sheet. You can store it anywhere on disk.

Assuming it's about SwT(TT), you can use a WRITEPRN("C:\swttt.prn"):=SwT(TT) to store the result.

In order to retreive it into a variable use e.g. SwTTTT:=READPRN("C:\swttt.prn").

By selectively enabling/disabling the WRITEPRN statement you can control when the result is calculated.

Note that the same remarks wrt accuracy/number of significant digits apply as when copying it....!

Success!

Luc

1-Visitor
February 27, 2012

Luc,

Would this work with Nested Arrays? Thought I'd have to "unest"/"nest" to WRITE/READ?

Thanks

Laurent

LucMeekes23-Emerald IVAnswer
23-Emerald IV
February 27, 2012

Laurent,

this does work with nested arrays, no problem (that is, in Mathcad 11) to any depth. Just try it out in your version.

Be sure to read the (nested) array in with Mathcad, and do not fumble with the data file outside of mathcad, unless you really know what you're doing.

But for your purpose, storing calculation results and retreiving them back in Mathcad, this should be no problem.

Success!

Luc