×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

How to execute MathCAD from command line (e.g. *.bat)???

How to execute MathCAD from command line (e.g. *.bat)???

How to execute MathCAD from command line (e.g. *.bat)???

(OP)
Hello,

I'm using MathCAD (among others) for manipulating pictures (RGBREAD, RGBWRITE, ...). I've to process more than 2000 bitmaps and I intented to do this over night in a loop. But because of the big image size (1680x1050) the memory limit is reached after 3 files !!! (task manager: RAM: 1,5GB avaible, 1,45GB used by MathCAD). MathCAD gives an error like "not enough memory". If I close MathCAD an restart it again, I can process annother 3 files.

1) Is there a possibility to FREE the MEMORY used by the variables (e.g. a big matrix; "M:=0" dos'nt work)?

2) If I write a batchfile (*.bat) with "mathcad.exe test.xmcd" MathCAD starts an executes the calculation. OK. Ist there a posibility to say that MathCAD should close itself after finishing the calculation ??? ("mathcad.exe test.xmcd /close" dose'nt work)

Thanks for hints.
Christian

RE: How to execute MathCAD from command line (e.g. *.bat)???

Once a variable is defined in the worksheet ( := ) you can not clear the memory by clearing the variable later in the sheet.  
However, I believe that local definitions within programs ( <- ) are not saved in memory when the calculation is done.  You could try setting up a loop within one program where all the variables are local definitions.  So the read file, processing and write file are all within one program, using only local definitions and nothing is saved at the worksheet level.  This 'might' help your memory problem.

Peter

RE: How to execute MathCAD from command line (e.g. *.bat)???

I thought A:=A undefines A.   Hopefully this will free up memory too.

RE: How to execute MathCAD from command line (e.g. *.bat)???

Nope.  No such luck.  The only place where Mathcad, particularly the newer versions, is reasonably efficient is in the middle of a program loop.

TTFN

FAQ731-376: Eng-Tips.com Forum Policies

RE: How to execute MathCAD from command line (e.g. *.bat)???

(OP)
Thank you for your replies.

Indeed it seems to be difficult to free the memory, which mathcad has allocated. To get a quick solution, I wrote a little C++ programm which
- starts mathcad with a certain *.xmcd-file
- reads a certain status file, where mathcad places an idication number after the calculation has finished
- kills the MathCAD-task
- restart MathCAD with the mext FRAME to process...

Christian

RE: How to execute MathCAD from command line (e.g. *.bat)???

"I thought A:=A undefines A.   Hopefully this will free up memory too."

Nope.  That'll just keep A equal to whatever was in A.

RE: How to execute MathCAD from command line (e.g. *.bat)???

Another option would be to use a Windows based mouse recorder. I used to have one that would open a given set of programs from one click. Sorry, I can't remember its name.

Cheers

Greg Locock

SIG:Please see FAQ731-376: Eng-Tips.com Forum Policies for tips on how to make the best use of Eng-Tips.

RE: How to execute MathCAD from command line (e.g. *.bat)???

2. taskkill /im mathcad.exe will kill it. Perhaps a timer could be implemented with a long enough delay to ensure calculations are complete before killing. Here is a batch file timer I've used:

echo Wscript.Sleep 4000> c:\batch\sleep.vbs
start /w wscript.exe c:\batch\sleep.vbs
del c:\batch\sleep.vbs

Increase or decrease the 4000 as needed.

RE: How to execute MathCAD from command line (e.g. *.bat)???

The way to do it is using the Animation feature. This uses the built in variable FRAME and runs the same proramme as many times as you require and each time Frame is the new value. Anything that depends on FRAME is updated and a small selected area is captured to make an avi (which is what it was designed for).
I regularly use it to batch process hundreds of test results from cameras, each which takes in hundreds of image frames. When used in that mode it does overwrite the memory space.

search the collab http://collab.mathsoft.com/~Mathcad2000 for FRAME to see all the explanations.

Also look for 'components' which allow you to process directory lists etc.

Philip

RE: How to execute MathCAD from command line (e.g. *.bat)???

(OP)
Thanks @ philipoakley,

I'm using the Animation feature very often for periodic (recurrent) calculaions. Normally this works good. But in this special case, it only processes two or three images and then MathCAD gives the described memory error - the evidence that MathCAD does NOT free the allocated memory (MathCAD 13).

It seems to me that it depends what you do with the images. If I only concatenate two images, no error occurs. If I do many complex things like copy one image into another (frame in frame) and append status bars etc. this error occurs. You can also force this error with a little example sheet, see following link:
http://home.arcor.de/Chr_Meissner/Public/Memory_test.xmcd

(In this synthetic case, the animation tool works good in many cases.)

Thanks @ stevenal,
I used this command (it works fine), a timer is also included and at the end of the MathCAD sheet, a "PRNWRITE" command writes a flag into a status file indicating that the calculation has finished. The C-software reads out this file and kills the MathCAD task if this flag is set.

Thanks @all for your replies. I think this problem is solved:
- MathCAD ist not as powerful as a "real" programming language (disadvantage)
- with MathCAD you can write a software and find mistakes very fast (big advantage)
-> Sometimes very special solutions are necessary (kill/restart, DLL, ...)

Thanks for all help,
Christian

RE: How to execute MathCAD from command line (e.g. *.bat)???

in the test...
So you have 1050 x 1680 x 3 x 2 data values, times 15 repeats. This makes 158,760,000 data values, each is an object, so will have multi-byte representation. Even as a simple double it is 600+meg, then all the .net overhead...

V13 may have leak, but it appeared to work OK for me in V14 (with a lot of disc thrash).

Don't forget you have fifteen different 'variables' called k, and fifteen different 'variables' called K. In fact, mathcad has no variables at all. They are all just the names of the constants they represent, and their placement signifies the start of their scope, until another constant of the same name ends it...

One trick is to put all the looping (the 15 steps) into a programme and have each bit of processing as a simple function (which uses no memory at the point of definition). You can copy out any intermediate values to review as part of the return matrix (which can be nested)

If you need more have a look at http://collab.mathsoft.com/~Mathcad2000

Philip

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login



News


Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close