Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

using vectors with Mathcad Given-Find blocks or using Given-Find blocks in a loop

Status
Not open for further replies.

mahumadac

Structural
Jul 1, 2015
3
0
0
CL
Hi there,

Looking up on the internet I found nothing about using vector variables in a MathCad Given-Find block, or using them inside a loop. Trying and trying I found a way.

This will be useful for those who want to solve several times the same equation using different parameters values and different guess values for the solve block, without having to use a Given solve block for each value at a time, but solving for all at once instead. It goes like this:

1. Define guess values variable as a vector the length of the number of equations you wish to solve
2. Start the Given block typing Given
3. Below the Given statement, type the equations you wish to solve as you would do for a single sized variable, but use the subindex indicator "[" next to each vector parameter or vector variable and put an undefined variable as subindex.
4. Define a function containing the Find funtion inside, with 2 parameters: the variable you wish to solve from the equation defined in step 3 and the variable in the subindexes I mentioned in step 3. This function should go like this: solveFunction(x,subindex)=Find(x)
5. Use a for loop or while loop to get all the solutions. Inside the loop, you must assign to each cell of a vector the "solveFunction" function with the "x" variable you want to solve (which is already defined as the guess values in step 1) and the loop counter variable as the "subindex" parameter. You actually will need to assign to each cell a subindex of the solverFunction (equals to the counter variable), since the solverFunction will return a vector the size of "x", with the current solution in the current loop counter number and all the oter values as the guess values assigned to "x" previously.

I hope this is useful. it was for me. Good luck!
 
Replies continue below

Recommended for you

The simplest approach is to assign the Find to a function whose variable is the one that will be changing:

Given

blah blah

f(x):=Find(y)

res[sub]i[/sub] := f(x[sub]i[/sub])

Note that a sufficiently pathological set of constraint equations might require customized guess values, but most of the time, that's unnecessary


TTFN
I can do absolutely anything. I'm an expert!
homework forum: //faq731-376 forum1529
 
Status
Not open for further replies.
Back
Top