Skip to main content
1-Visitor
July 4, 2012
Question

Mathcad worksheet as a function

  • July 4, 2012
  • 2 replies
  • 13857 views

Hi forum

I was wondering if anyone know if it is possible to use a worksheet in a similar way as m-flies functions (Matlab) e.g. turn worksheet "alfa.xmcd" into a function which can be called from another worksheet?

Best regards Dan

2 replies

24-Ruby III
July 4, 2012

Hello,

In main menu select "Insert" -> "Reference" and then choose your worksheet with prepared function:

Pic_1.PNG

Pic_2.PNG

DanMadsen1-VisitorAuthor
1-Visitor
July 4, 2012

Thanks Vladimir

The functionality I'm after isn't a single function in the worksheet, but the opportunity to use it as a function for an itterative analysis e.g. for monte carlo analysis which is seeded with random values every time the worksheet is called.

I've resently found out that the worksheet can be added as a scripted component (VBscript), but sofar I've only been able to assign a static value to the component output... I'm looking into this.

Btw. havn't written a single line of VBscript before, so if anyone know in advance that this is impossible to do with a scripted component, then please let me know

23-Emerald V
July 6, 2012

Yes, your fix addresses that particular issue, but at a fairly high cost on my machine. What it appears to do is re-initialize the embedded worksheet which means runif returns the same sequence of values every time (albeit of varying length). It also imposes a noticeable performance overhead.

I can get round the first problem by adding a Seed statement prior to runif and making it dependent upon time(). Can't do much about the performance though.

However, back to the original use and the problem of Solve blocks which I've also suggested this as a solution for, I've enhanced the worksheet slightly by adding part of one of the Quicksheets as a component and shown two ways of using it as a function.

Stuart

Important Notes:

Note 1: If you want to make any changes to the embedded worksheet, you must save it using 'Save' from the main File menu whilst editing the embedded worksheet; if you don't, then the changes will be lost as soon as it's executed.

Note 2: Ensure you close all instances of Mathcad before opening worksheets with embedded Mathcad components; if you don't then it won't work (corrupted region upon load) but will reset your default worksheet size and toolbar positions/sizes.

PS. I hate this ruddy editor - it's Undo is useless

24-Ruby IV
July 4, 2012

Mathcad worksheets as a cloud functions.

See please

http://twt.mpei.ac.ru/ochkov/WSPHB/Web-function-Power-Eng.pdf