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

Community Tip - Did you get called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. X

how to save calculated data for later use so that Mathcad does not recalculate every time I open the worksheet

ptc-5782298
1-Visitor

how to save calculated data for later use so that Mathcad does not recalculate every time I open the worksheet

Hi all,

I know that a related question has been asked, but it seems complicated for me to impliment. So, I was hoping if there is a easier way out. My problem is as follows:

I have a mathcad code that takes about 30 mins to calculate and it crashes often whenever I tried to change the axis limits. So, if there is a way to store latest calculated result so even after crash mathcad does not need to recalculate everything. I am importing and exporting data using insert>data>file input (or file output), so it is not a problem of saving data to or reading data from an outside file, but just that it would be nice that Mathcad does not crash or at least that I do not need to spend 30 mins to recalculate every time it crashes.

Many thanks in advance!

Newin

25 REPLIES 25

Before saving calculated document in main menu uncheck "Tools" -> "Calculate" -> "Automatic Calculation":

Pic_1.png

Hi Vladimir,

Thanks for your reply. However, this is not what I am looking for. What I am after is a way to not having Mathcad to 'lose' all its calculated result when it crashes or when I close it. Remove the auto calculation will just not doing any calculation (and no results) until I press F9 or Ctrl+F9.

What I woudl like to have is that the calculated data are there when I open Mathcad without needing to press F9 or activate automatic calculation.

Do you have any suggestion?

Cheers,

Newin

Werner_E
25-Diamond I
(To:ptc-5782298)

Only way I can think of is that you save the calculated data yourself in a file (WRITEFILE, WRITEPRN, WRITEEXCEL,....) and read it in when opening the sheet again. As the sheet needs so long to do its calculations I guess you will have turned off autocalc anyway and evaluate expressions singly with F9, so on startup after a crash no recalc is done and you can manually activate the appropriate READ... command to get your data in.

Hi Werner,

With writing and reading the data, I assume that if I modify any parameter, I will need to do all the calculation again. I think what takes long is the symbolic calculation. The step where I input number of each of the parameter does not seem to take long .Do you have any advice on possible solution to expedite the calculation, like hiding symbolic output or similar?

Newin

Werner_E
25-Diamond I
(To:ptc-5782298)

I think I still not fully understand the problem. You have a calculation which runs very long and it needs to run that long again if you change certain parameters. I doesn't look like you can avoid that, doesn't it?

But It thought that you are doing some other calculations after the long one and wish those to be done after a crash without having to do the long one. So my suggestion was you save the results of the long calc, disable autocalc (or disable the long calc at all, preferrably if its put in a single function or is done in an extra called worksheet) so on restart you would simply read in the precalculated data and off you go.

Looks like thats not an option for you?

I am also not sure what "hiding symbolic output" should mean.

Maybe you can setup a small demo sheet to demonstrate what you are expecting (not your original one, as few people would be willing to wait for a 30 minute calculation to finish).

Hi Werner,

Please see attached the demo. I included text to explain what I would like to have. By 'hiding symbolic output' I mean that by not asking Mathcad to display the output it might be possible to save some resource and thus time

Newin

RichardJ
19-Tanzanite
(To:ptc-5782298)

I would copy and paste the final result to a new numeric function. Then I would disable the symbolic calculations, put them in an area, and collapse it. In fact, I have a number of worksheets where I have done just that, because although I want to keep the symbolic math for future reference, I do not need it for day-to-day use, and (as you note) it's slow.

Werner_E
25-Diamond I
(To:ptc-5782298)

I think I understand - the long calculation are "only" producing symbolic results. These can't be written to a file and I don't know of any other method to preserve them.

So I can't think of anything other than what Richard already suggested - manual copy and paste.

Maybe it would be possible to avoid all or most of those symbolic calculations if you set up your function with all variables as arguments in the first place. The only symbolic eval needed in you demo seems to be the one using solve. If you are just after numeric values and plotting, it may be possible to replace it by a solve block.

Thanks Richard, Werner, I will try to do what you suggested.

By the way, I am new to Mathcad, can you suggest a place other than Help feature in Mathcad where I can look for more details on how to create a function and a solve block?

Many thanks,

Newin

The sample worksheet you provided takes about 3.7 seconds on my PC to initially calculate the symbolic and numeric results, and 1.7 to recalculate. This is significantly different than the minute you indicate in the notes.

Have you considered that some of your issues are machine related?? What version of Mathcad are you using??

Which version of Mathcad are you using??

Try splitting your calculations into several worksheets and read/writing to data files to pass information from one worksheet to the next.

Werner_E
25-Diamond I
(To:MichaelH)

The problem seems to be that its not the numerical data which should be preserved but the symbolic results, which cannot be saved to a file. So either rewriting the sheet to avoid the need for those symbolics or the manual copy and paste as Richard suggested seems to be the only options.

Is there a away to copy the equation that is a result of a symbolic calculation that Mathcad says is too large to display?

Newin

tietjee
15-Moonstone
(To:ptc-5782298)

Newin,

I have several worksheets that read in large amount of data, analyze, and plot. Some take over an hour to process. Part is the reading of the data and part is the analysis. Depending on size of data and other programs running, crashing has not been a real problem. I have tried several methods to decrease the time to re-calculate.

  1. Calculate the worksheet after openning. Data that has been read, will not be read a second time. Depending on the variable changes, they may not be re-calculated either.
  2. Place the curser at the location where the calculation should stop and use F9.
  3. When working in one area of a worksheet, disable some of the time consuming functions. This will allow more interactive changes to the worksheet.
  4. Read in multiple data files using a matrix. This will execute the reads all at once. This works only with the READEXCEL command.
  5. Using reference worksheets may speed up the process. I have found that the reference worksheet is sometimes recalculated. The reference worksheet can be placed at the end of the active worksheet, if global commands are used. I tend to stay away from reference worksheets.
  6. When working in one area of a worksheet, disable some of the time consuming functions. This will allow more interactive changes to the worksheet.

It takes some practice to optimize large worksheets.

There is a "time" function take will measure calculation time. Consider using this to identify time consuming functions.

Hope this helps,

David Tg

Hi David,

Thank you for your detailed suggestions. These will be very useful in my day-to-day coding. But as you rightly said, it will take some practice

Newin

RichardJ
19-Tanzanite
(To:ptc-5782298)

No. Have you tried adding a simplify keyword to make it smaller (adding an assume, and constraing the variables to be all real or all positive can help sometimes when you simplify)?

Hi Richard,

I already included assume and constraining the variables to be all real. I also try all positive, but this does not help much. I am now try what Werner is suggesting and it seems to help, but I am not finished yet

Newin

RichardJ
19-Tanzanite
(To:ptc-5782298)

Can you post a worksheet with the actual symbolic math? If so then I may be able to capture the solution in Mathcad 13, which allowed much larger results to be displayed (after many years of complaints, in MC13 they finally allowed larger results to be displayed. Then in MC14 they changed it back. I have no idea why).

MichaelH
12-Amethyst
(To:Werner_E)

I agree. Manual copy and paste would seem to be the only way.

However, since the symbolic calcuation is only needed once, this would not seem to be an insurmountable issue.

Hi Michael,

Many thanks for your post. There are so many great ideas here and I will try them all, but this will take time though as I am still a beginner!

Right now I am trying what Werner has suggested, but linking different worksheets like you said sounds interesting too.

Newin

Werner_E
25-Diamond I
(To:ptc-5782298)

Here is your demo file rewritten without using a single symbolic evaluation. I am sure it could be further streamlined and simplified - I simply strictly followed your sheet line by line.

The plot now takes quite a lot of time as the solve block has to be evaluated again for every of the 10^4 points plotted. So it might be a good idea to use precalculated symbolic results if possible (if they are not subject to change). See attached sheet for an example.

Hi Werner,

Thank you very much for the sheet and I am sorry that it has taken so long before I reply. I had a meeting last week and got drifted away early this week.

I am working on your sheet to extend it to my actual problem. However, I am stuck at this little problem of making a matrix as attached. I do not remember how it was made. I think Alan helped me doing that.

Anybod here know how to make such a 'nested' matrix? I need to put them all in one single equation for the solve box. OF course I could put them in one big matrix, but it would be nice to have it as in the attached for the reason of clarity.

Many thanks in advance,

Newin

PS

I am also trying what Richard said. However, the problem is that I can't copy and paste all the symbolic results because they are too long and Mathcad does not like to display it.

Werner_E
25-Diamond I
(To:ptc-5782298)

Ad nested matrix: So you are still trying to use symbolics solve? You can't insert a matrix inside a matrix via Ctrl-M or the matrix creation button. Easiest way is to type the first equation somewhere on the sheet and copy and paste it to all five placeholders of the 5x1 vector. then edit the others to your needs.

Hi Werner,

I think what I am doing is wrong. In fact, I am trying to expand on your file to include more equations. In your demo file there are only two equations. I think to expand on yours I will need to make the matrix M very large in order to keep all in just one equation, or is it possible to put this 'nested' matrix after 'given' before we apply the Find statement?

Werner_E
25-Diamond I
(To:ptc-5782298)

I am not sure which matrix you are talking about. In the file I posted there is no matrix consisting of equations.

Oh, I think I got it. Yes, you can put your matrix after given and you don't have to use just one single equation in a given-find block. A solve block can be quite long and may consist of a multitude of single equations and constraints.

Announcements

Top Tags