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

DanMadsen1-VisitorAuthor
1-Visitor
July 5, 2012

PS. I did manage to create a Mathcad Component in M15 and to get a variable value from it (using ScriptObj.Worksheet.GetValue(varname)) but attempts to load the worksheet resulted in bad region errors.

I've been able to get a calculated value passed from a Mathcad worksheet component using the script command mentioned above. This component is simply another mathcad worksheet which is seeded with a random number and returns a different result every time it runs.

I thought if I made it into a function e.g. f(x):=component and called it from a sequential block, then I would be able to force a recalculation of the component. This however is not the case since it returns only the result of the first run. (calling it ten times returns the same constant ten times)

But on the bright side, it seems to work without bad region errors in my case.

Any forced recalculation of a component advice would be very much appreciated.

edit: I'm on Mathcad 15 M005 and M010

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