Dear Mathcad community,
I made an elaborate Mathcad 15 sheet about the offshore pipeline stability according to the DNV code. The sheet turned out to be very elaborate abouth 25 pages of calculations, including iterations, interpolation in tables etc. The sheet works fine and I am very happy with the sheet .
However, I would now like expand this sheet so that I can see the stability of the pipeline at multiple locations in the same sheet. I would like to avoid saving my sheet for one location and then save another for another location. I thouhgt of these options:
What do you guys suggest how I should tackle this problem? Do you have better solutions to the ones I have stated above?
As an example of how elaborate my sheet is I have attached an input matrix I had already constructed:
Thanks in advance.
Kind regards,
Sagar Mungar
Solved! Go to Solution.
Here is an alternative method which follows the line of copying the calculations multiple times (but without really doing so).
You simply set up two worksheets. The first one (I called it "Calc") would be your 25 page sheet but without the variables defined you want to change. Don't mind the red errors for now.
Example of Calc.xmcdz:
Now create another worksheet, define the variables, insert a reference to Calc.xmcdz and display the calculation result. Then define the next set of variables, insert the next reference, etc.
Inserting a reference acts like you copy the content of that file in that place of your new worksheet. You could as well put your calculations in a collapsed area and copy this area multiple times, but then you will have more work if you need to change something in your calculations as you will have to do the copying again. The drawback of a reference on the other side is that you have to handle and keep together two different files.
As you probavly use units the method with the matrix consisting of all variable sets will not work in Mathcad 15 and below because we are not allowed to keep values of different dimensions in one matrix. But is should be no problem to provide the values singly as shown in the last example below or you may use a single vector for each variable:
After reading the thread http://communities.ptc.com/thread/37395, I think the best solution for me is:
use the Input matrix, select which location to consider (or make a loop) use the functions readprn, writeprn and appendprn to get the results back in the mathcad sheet.
This is how lucmeeks discripes it in thread 37395:
've come across this as well. Here's my solution and, not to surprise, it's been suggested above already:
1. make sure that each result is in the form of a single matrix row. (I've no experience with row elements being other than scalar, but I'm pretty sure that strings as elements are allowed too, not sure about about vectors or matrices)
2. Write the result of the first pass with WRITEPRN
3. Write the result of each subsequent pass with APPENPRN. If you try to append a row of different size, you'll get an error.
4. Now you can read in the datafile with READPRN, you should get a matrix with as many columns as there are elements in your original rows, and as many rows as there are passes saved.
5. Process this matrix as you like.
Do you guys agree with me? I think it is the best solution.
As you sure know yourself the drawback of your solution is that your sheet will not calculate automatically. You have to delete the file you write your results to first and then manually one by one select the different data columns the calculation should be done with and recalculate the sheet. But I guess it should work. We can not turn a whole sheet into a function in Mathcad so the alternative would be to redesign your sheet completetly and turn every calculation into a function of the variables which may be changed. At the end you can call a single function with the values of a specific location and get te result for it and can do for all the other locations as well. But rewriting the 25 page sheet that way would be quite tedious task and readability may be difficult for people not acquainted to a functional approach (A:=a*b versus A(a,b):=a*b).
And, yes, you can put strings in a matrix and you may also nest matrices and vectors - se here:
But be careful with nested matrices and don't push it too hard. If in the example above N would be nested and contain another vector/matrix, WRITEPRN will fail. It will behave like being in an endless loop. Guess thats a bug.
Here is an alternative method which follows the line of copying the calculations multiple times (but without really doing so).
You simply set up two worksheets. The first one (I called it "Calc") would be your 25 page sheet but without the variables defined you want to change. Don't mind the red errors for now.
Example of Calc.xmcdz:
Now create another worksheet, define the variables, insert a reference to Calc.xmcdz and display the calculation result. Then define the next set of variables, insert the next reference, etc.
Inserting a reference acts like you copy the content of that file in that place of your new worksheet. You could as well put your calculations in a collapsed area and copy this area multiple times, but then you will have more work if you need to change something in your calculations as you will have to do the copying again. The drawback of a reference on the other side is that you have to handle and keep together two different files.
As you probavly use units the method with the matrix consisting of all variable sets will not work in Mathcad 15 and below because we are not allowed to keep values of different dimensions in one matrix. But is should be no problem to provide the values singly as shown in the last example below or you may use a single vector for each variable:
Thanks a lot Werner, this is really really helpfull, I am implementing it now. The disadvantage of using two sheets really outway the advantage. Thank you.
I will let you guys know how it went.
Sagar Mungar wrote:
Making a function of actually the entire sheet. Is this possible if you have iterations?
This capability is Looooonnnnnngggggg standing feature request, or even creating a special form of Area that will accept arguments and allow the user to effectively write a function in 'standard' Mathcad layout rather than writing a function ....
Stuart
I had a quick dig around in the PTC Community, and found a couple of files that give some of idea of what can be done now to a limited degree, but which give a bit more of a flavour of the feature request and what it should be possible to do.
http://communities.ptc.com/message/185076#185076
http://communities.ptc.com/message/183988#183988#183988
http://communities.ptc.com/message/185232#185232
Stuart
The picture below is of an embeded worksheet returning values - but the method is a bit flaky and should be a lot simpler to do (and directly at the worksheet level, without having to play around with scripts ...)