## Placing "Given" solve blocks into loops

## Placing "Given" solve blocks into loops

(OP)

I was wondering if there was a way to place a Given sove block within a while loop or for loop. For instance, I would like to solve:

For x = 1-9

Given

f(x,a) = h(x,a)

Find(a)

Typically, I would just enter in x as a vector of numbers, however the system of equations I want to solve for is quite complex and does not permit vectors of data to be inputted. Thus I am restricted to having x = a constant. This means I have to vary x by hand and record the results of a by hand. This is not very robust, and I know there has to be an alternative way. Any help would be great.

CDR

For x = 1-9

Given

f(x,a) = h(x,a)

Find(a)

Typically, I would just enter in x as a vector of numbers, however the system of equations I want to solve for is quite complex and does not permit vectors of data to be inputted. Thus I am restricted to having x = a constant. This means I have to vary x by hand and record the results of a by hand. This is not very robust, and I know there has to be an alternative way. Any help would be great.

CDR

## RE: Placing "Given" solve blocks into loops

HTH,

Imagineer

## RE: Placing "Given" solve blocks into loops

CDR

## RE: Placing "Given" solve blocks into loops

I ran into the same problem. I had a set of 3 non-linear equations that I needed to solve. However, the solutions to the set was heavily dependent upon the initial values you input as guesses.

To get around that problem, I needed to automate the selection of guess values I used as inputs. My solution is as follows. If anyone else has a more efficient solution, please let me know!

Install VisSim -- it came on the Mathcad 2001 installation CD. It allows you to insert Mathcad object blocks and connect them using signal wires.

Insert a Mathcad object. You will need to assign your input values from the internal variables in0, in1, in2, etc to your guess variables of your Find() block. Starting from the top, the black arrows on the left side of the Mathcad block represent in0, in1, in2. You can add or delete inputs (and outputs) so that you have as many as you need. Your mathcad object should save your data to a file. I changed my filenames to reflect what input values I used.

Next, insert a file input block for each variable. Connect the file input blocks to the mathcad object. You may have to format your data into 2 columns -- leftmost column is the time (in the simulation) that the data is sent through the wire. The second column is the data that you want sent.

You may need to put a dummy line at the end of your mathcad block that says 'out0 := 1' or something, and put a display block connected to the output. This will make VisSim completely process your entire Mathcad file before it goes on to the next time value. Also, the mathcad server may become busy and you'll have to continue pressing enter.

Then once you get your data files, you can import the data into Mathcad with the READPRN command (or a file input object) and process it from there.

This process is quite lengthy and cumbersome but it is the only way that I have found that will work.

If anyone from Mathsoft is reading out there, PLEASE PLEASE work on supporting Given-Find blocks in the Mathcad programming loops in the next version!! (For you newbies out there, try typing in the word 'Given' into the first line of a programming structure and watch Mathcad crash and burn.....)

Hope this helps,

Matt

mattman206@hotmail.com

## RE: Placing "Given" solve blocks into loops

usign the Given-find block solver, then access the function

using a loop inside your MathCAD program.