Skip to main content
1-Visitor
May 8, 2014
Solved

comparing previous value

  • May 8, 2014
  • 2 replies
  • 2655 views

I am working on a mathcad worksheet where I read data from external excel file. Every time I open the mathcad worksheet, it reads file and does calculations. My question is - is there a way to remember a previous value of a certain variable with its new value and calculate the difference betwwn two?

Best answer by AndyWesterman

It is possible to save the value(s) using a function I found on this forum, hopefully it will work well enough for you.

Attached file accepts user input & compares against the previously saved value.

NB: <ctrl> F9 to recalculate the sheet will save the current value & give an "Equal" result.

Regards

Andy

2 replies

12-Amethyst
May 8, 2014

It is possible to save the value(s) using a function I found on this forum, hopefully it will work well enough for you.

Attached file accepts user input & compares against the previously saved value.

NB: <ctrl> F9 to recalculate the sheet will save the current value & give an "Equal" result.

Regards

Andy

1-Visitor
May 8, 2014

How can I use it to compare multiple values in an array / matrix? I changed "Value" to one column array, but it gives error.

12-Amethyst
May 8, 2014

Saving more data is relatively easy, attached file will save data from simple variable , vector, or 2-D matrix & recover it .

If all you need is a difference then that becomes a simple subtraction.

However, if the data size can vary there are a few new issues to consider.

eg changing from a 1* 2 to 2 * 1 matrix may cause the comparison to fail.

changing from 3*1 vector to 3 * 4 matrix seems to repeatedly subtract the vector from each column - may be what you want or it could be an error - depends on your requirement.

regards

Andy

25-Diamond I
May 8, 2014

Why don't you save the values you wish to keep anmd compare in a file ynd later readin that file and the current Excel sheet?

1-Visitor
May 8, 2014

I was trying that, but its one addional file to handle while storing and/ or sending it in email etc, so I will prefer if it can be done in mathcad itself