cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X

Combining two arrays using augment

SFares
12-Amethyst

Combining two arrays using augment

Hello,

I'd like to combine the load array with deflection array using augment. I am getting an error. It is MathCAD 15.

SFares_0-1664472546843.png

Thank you for you help,

Sam

1 ACCEPTED SOLUTION

Accepted Solutions
Werner_E
24-Ruby V
(To:SFares)

Luc is perfectly right with his assumption that your P.i uses a literal index.

Unfortunately even if you turn P and S(P) into vectors you would not be able to augment the two vectors into one matrix. Reason is that Mathcad does not allow quantities of different dimensions in one matrix (thats one of the few advantages in Prime). And P.i is force (lbf) but S(P.i) is length (mm).

 

So you may create vectors as Luc suggested but you have to divide them by the appropriate units before you augment them, or you may use a small program to create a table with headers like shown below:

Werner_E_0-1664484682504.png

You should use makeTable(101) to create a table with all the 101 values you use in your plot.

 

BTW, it looks to me that the various pictures in your file stem from screenshots made at a high resolution display. After inserting them in the Mathcad file you scaled them down. Mathcad doesn't do a good job here and thats the reason why the pics look that ugly and hardly readable.

You get a much better result if you use any picture editor to scale the pics down and insert the modified pics without scaling them in Mathcad.

Below is an example of a comparison using the first picture in your file, on top how it looks in your file now and then followed by a version which was scaled before inserting it. An additional advantage is that the files also gets much smaller that way. Even though Mathcad displays the pictures at the smaller size you scaled it to it stores it in full original resolution.

Werner_E_1-1664485769533.png

 

 

 

 

View solution in original post

6 REPLIES 6
LucMeekes
23-Emerald III
(To:SFares)

You can use augment() only with arrays, and your P.i is NOT an array, but a range, and so S(P.i) also results in a range, NOT an array.

I bet that the i in P.i is a literal subscript, not an index.

 

In order to create P as an array you might:

i := 0..100

P[i := i*100*lbf

 

Note that you have to type P[i, not P.i, to get i to be the index into the array P.

Now with P being an array, you should change the definition of S:

S[i := (same expression, but change each P.i to P[i).

Further down you want to change P.i to P , and S(P.i) to S, for display of the arrays and inside the plot.

Then the augment, here too change P.i to P , and S(P.i) to S now resulting in a new error:

You cannot have multiple (differently) united values in one array. If you really, desperately need that, use Prime.

If you can live without that, strip the units from P and S array before augmenting them.

 

Success!
Luc

SFares
12-Amethyst
(To:LucMeekes)

Thank you Luc!

I believe I  made the changes you suggested but  the results array still showing 0s  as shown below

 

SFares_1-1664484131059.png

 

LucMeekes
23-Emerald III
(To:SFares)

That is due to your: i := 0, 5 .. 100,  (stepping 0, 5, 10, 15 etc to 100) instead of i := 0 .. 100 (using the default step of 1)

 

Success!
Luc

Werner_E
24-Ruby V
(To:SFares)

To get what you obviously want ( a smaller table) you should use

i := 0 .. 20

P[i := i * 500 lbf

 

or use my function from my first answer with argument 21 -> makeTable(21)

Werner_E
24-Ruby V
(To:SFares)

Luc is perfectly right with his assumption that your P.i uses a literal index.

Unfortunately even if you turn P and S(P) into vectors you would not be able to augment the two vectors into one matrix. Reason is that Mathcad does not allow quantities of different dimensions in one matrix (thats one of the few advantages in Prime). And P.i is force (lbf) but S(P.i) is length (mm).

 

So you may create vectors as Luc suggested but you have to divide them by the appropriate units before you augment them, or you may use a small program to create a table with headers like shown below:

Werner_E_0-1664484682504.png

You should use makeTable(101) to create a table with all the 101 values you use in your plot.

 

BTW, it looks to me that the various pictures in your file stem from screenshots made at a high resolution display. After inserting them in the Mathcad file you scaled them down. Mathcad doesn't do a good job here and thats the reason why the pics look that ugly and hardly readable.

You get a much better result if you use any picture editor to scale the pics down and insert the modified pics without scaling them in Mathcad.

Below is an example of a comparison using the first picture in your file, on top how it looks in your file now and then followed by a version which was scaled before inserting it. An additional advantage is that the files also gets much smaller that way. Even though Mathcad displays the pictures at the smaller size you scaled it to it stores it in full original resolution.

Werner_E_1-1664485769533.png

 

 

 

 

SFares
12-Amethyst
(To:Werner_E)

Thank you so much Werner!

 

Sam

Top Tags