Skip to main content
1-Visitor
October 29, 2012
Question

arguments inside the "augment" function

  • October 29, 2012
  • 1 reply
  • 3997 views

Hello,

I'm using Mathcad 14 to write my diploma thesis. I ran into trouble optimizing existing code. The for-loops don't run properly as soon as I work with more than approximately 100.000 points while matrix-operations are working well beyong 1.000.000 points. This is why I'm trying to rewrite the existing code (which heavily depends on for-loops) with matrix and array-operations. It is working pretty good so far, but I keep running into trouble usin the "augment"-function.

This is the situation:

I have a meshed surface which is copied (n-1)-times using a parameterized command. The coordinates of the points are being saved in a nested array called "Array". "Array" has three subarrays; one for each cartesian coordinate-direction. Each of these subarrays contains n subsubarrays (the initial configuration is counted as well) each containing the coordinates of one configuration.

If this is plotted Mathcad is unable to plot a single 3D-surface. This is why I need to rearrange them using the augment-function ("erweitern" in German)

matrix:=augment(subsubarray[0,subsubarray[1...subsubarray[n)

Manually entering the argument of the "augment"-function works, but I need to parameterize this as well (Otherwise in case the input-data is changed only a fraction of the needed results is displayed withoug manually adjusting the argument of the augment-function).

Here are some things I tried and the results:

  • Creating a list i:=0..n and applying it to my subsubarrays[i. This is exactly the same as the input
  • Using a for-loop to apply i similarily to my subsubarray's name....Same result.

Does anybody know how I can automatically generate a list of this kind:

subsubarray[0 , subsubarray[1 , ... , subsubarray[n

This list needs to be divided by "," and without using a for-loop (because they create memory-overflows quite easily)

Thanks in advance!

Jon

1 reply

23-Emerald IV
October 29, 2012

Hi Jon,

I assume your subsubarry[i are all the same length.

What you can do is write them out to a file and read them in as a matrix.

I'm assuming subsubarray is an array (column vector=single column matrix) of arrays (each again a column vector). Then here's the outline of the method. The attached .MCD file has all..

ConvertToMatrix.png

You need to be aware of the fact that PRN files only store the amount of digits that you specify in mathcad settings, you may loose some accuracy.

Hope this helps.

Oh, and you may want to delete the files created by the routine afterwards, or keep them as a backup.

Success!

Luc

1-Visitor
October 30, 2012

Hi Luc,

I downloaded your file, but your command is not working. The error displayed is "file-creation error". I tried it on two different computers using different operating systems. Both return the same error.

But I got to be honest...Even with the manual on hand...I understand only half of what you have been writing...

Jon

23-Emerald IV
October 30, 2012

Hi Jon,

I developed this program on MathCad 11, and it runs without problems on my computer (Native WinXP). I don't have Mathcad 14 at hand.

Some scenarios:

Are you using a German version of MathCad? Does it know the functions that ConvertToMatrix() uses?

=> Where necessary translate.

Do you have write permission on the root of drive C:

=> If not, change the first string of the program (now: "C:\") to point to a path where you do have write permission.

It is possible that Mcad 14 does not create a file when APPENDPRN is called, it requires the file to be existent.

=> I modified the program to first create a file, then append to it. See attachment.

In case the above don't help:

If you right-click on the calling statement that displays the "file creation" error message, you can trace back to within the program where the error occurs. I'd like to know exactly at what statement.

Success

Luc