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

Community Tip - Visit the PTCooler (the community lounge) to get to know your fellow community members and check out some of Dale's Friday Humor posts! X

arguments inside the "augment" function

ptc-4788437
1-Newbie

arguments inside the "augment" function

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

6 REPLIES 6
LucMeekes
23-Emerald III
(To:ptc-4788437)

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

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

LucMeekes
23-Emerald III
(To:ptc-4788437)

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

Hello,

What version of Mathcad are you using? It works fine in Mathcad 15 M010.

LucMeekes
23-Emerald III
(To:ptc-4788437)

Jon,

Another option why the function may fail for you is when you typed the function from the picture into a mathcad sheet instead of using the mathcad sheet I provided. The function in the picture uses the C:\TEMP directory to store the temporary file. If that directory does not exist, the function fails at the first write (APPENDPRN) attempt.

=> Use the function as stored in the ConvertToMatrix.mcd.zip attachment.

Success!

Luc

I can't get it to work...but it's OK...I decided to keep the for-loops for now. The calculation works with enough datapoints for now. And I was able to rewrite critical commands in matrix-form.

But thank you for your help anyways.

Top Tags