Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations GregLocock on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

"augment" in a for-loop

Status
Not open for further replies.

JohnyWalker

Mechanical
Oct 5, 2012
3
Good morning everybody,
I started working with Mathcad about 2 weeks ago and it's working out pretty good so far. But yesterday I ran into a problem I could not solve:

I have an array "NAME" which consist of n (with current data n=9) subarrays, each with the dimension {1,5}. These subarrays contain all x-coordinates of a modell, so I have two more arrays that need to be handled the exact same way.

The subarrays of each array need to be writen into one array which: Doing this manually works with:

KOORDX:=augment(NAME0,NAME1,...........,NAME8)

As you can see, this becomes rather intricate (3x9 subarrays...) to handle, especially since the preceding calculations (11 pages in total) are fully parametric and so the number of subarrays varies with the input.

I tried implementing "augment" into a for-loop but I can't get it to work.

SORTING=FOR i element 0..(n-1)
Xi <- augment(NAMEi)
same with Y
same with Z
VECTOR <- (X,Y,Z)T

But doesnt return what I need.

I added a mathcad-file with my syntax and the problem...
 
Replies continue below

Recommended for you

I can't upload my file for some reason, so here's a screenshot:

mm2n2geo.png
 
You've used an illegal reference. You've defined TEST to be a function, and therefore, you cannot reference it as a variable. You can, however, use TEST(XCOORD)[0, TEST(XCOORD)[1, TEST(XCOORD)[2 to extract the nested arrays.

TTFN
faq731-376
7ofakss
 
Thank you, I see my mistake regarding the variable / functions name.

But your suggestion regarding the extraction doesnt help me. I know how to do it manually, but I when using the tool I'll have an unpredictable number of arrays which is previously calculated and named "nAxZaehne". With the current inputs this equals 9, but is going to change as soon as I change the input-data (which will happen as soon as we start using the tool). Therefore I need to programm a function with a for-loop, with automatically updating limits (0;nAxZaehne) so that every time the subarrays are automatically augmented.

Writing all subarrays manually into the "augment"-function works as I've shown in the screenshot's fourth line. But any construction using a loop does not work.

Here are some further things I tried but could not make them work:

variablename:=augment (for i € 0;(nAxZaehne-1))
subarray[i

This returns only the very last subarray with the index nAxZaehne but none of the previous ones...

for i € 0;(nAxZaehne-1)
augment(subarray[i)

Same problem here...it doesn't seem to matter wether I put the augment-function into the augment-function's argument or write it beforehand...Logically speaking this is strange...The first example does not repeat the augment-function but rather counts through the subarrays and the second one uses the augment-function according to the limits. But both return the exact same output...

Does anybody know how I can use the for-loop with "augment", so all subarrays are returned?
 
you are not making sense now. AUGMENT is a method for combining smaller arrays into a single large array, so what do you mean by, "so all subarrays are returned" In any case, your programmatic approach is nothing like what you did with the in-line AUGMENT, wherein you essentially concatenated three arrays into one.

In a programmed approach, you would augment the first and second, and then augment that result with the third, and so on.

TTFN
faq731-376
7ofakss
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor