Skip to main content
11-Garnet
Oct 2, 2014 4:37 PM UTC
Solved

How to search (find) and replace math terms like identity(3)

I am sorry, because I guess that my question is either very trivial (and I missed it), or without positive answer.

I need to change in a Mathcad (v.11 still, but I tried also with v.15) a matrix dimension from 3 to 2.

I have several equations, with "identity(3)" function, that needs to be corrected accordingly. I thought that the replace command would suffice to make a global change. Yet there is no way that Mathcad finds (both regions selected) the terms "identity(3)" in my worksheet, even if they are there. The culprit seems the bracket character.

Is there a way to make the find/replace command work? Thanks.

Werner_E
Werner_EAnswer
25-Diamond I
Oct 3, 2014 10:48 AM UTC

A rather crazy idea which I would not recommend at all is to redefine the identity function at the top of the worksheet

Don't comment on the readibility of that worksheet 😉

1.png

16 replies

23-Emerald V
Oct 2, 2014 4:48 PM UTC

anthony Queen wrote:

I am sorry, because I guess that my question is either very trivial (and I missed it), or without positive answer.

I need to change in a Mathcad (v.11 still, but I tried also with v.15) a matrix dimension from 3 to 2.

I have several equations, with "identity(3)" function, that needs to be corrected accordingly. I thought that the replace command would suffice to make a global change. Yet there is no way that Mathcad finds (both regions selected) the terms "identity(3)" in my worksheet, even if they are there. The culprit seems the bracket character.

Is there a way to make the find/replace command work? Thanks.

I don't think there is, unless you feel like saving the file as an xmcd file and then using a text editor to find and replace instances of the corresponding xml strings.

The ability to search and replace on expressions has long been on my wish list - it ought to be possible for the user to just copy an expression, paste it to the find box and have Mathcad find the whole thing, including operators (such as +).

One of the things I've learned is to avoid hard coding numeric constants into my programs. I find it's far easier, both during development and maintenance, to define all constants using a variable.

Stuart

Translate
11-Garnet
Oct 2, 2014 5:03 PM UTC

Many thanks StuartBruff.

The find command works correctly with "identity" and "3" in two separate searches. But not "identity(3)" in one go. I was hoping in some special characters like "*" or "?" used in Dos to avoid the undentifiable brackets. But I did not have luck. You seems to confirm this. I now undertstand your wise attitude towards constants.

Translate
1-Visitor
Oct 3, 2014 6:18 AM UTC

Could you not use special K mode and refine the variables to allow find to work?

Translate
1-Visitor
Oct 3, 2014 6:58 AM UTC

Maybe you could post an example and we can see if there is a way to automate what you are trying to achieve.

Translate
23-Emerald V
Oct 3, 2014 7:25 AM UTC

It should definitely be possible to automate it by doing an xml search & replace, especially for a simple expression where you can really work out the replacement string. However, a more general capability would likely prove to be "interesting", as it would need to translate the user-level strings into their xml equivalents ... Unless you could work out how to use the Mathcad GUI, or something like equation editor, to input expressions?

Stuart

Translate
1-Visitor
Oct 3, 2014 7:30 AM UTC

StuartBruff wrote:

It should definitely be possible to automate it by doing an xml search & replace, especially for a simple expression where you can really work out the replacement string.

Stuart

This was the sort of thing I was thinking about. However, I believe an example is required from Anthony to decide on the best option.

Translate
Werner_E
Werner_E25-Diamond IAnswer
25-Diamond I
Oct 3, 2014 10:48 AM UTC

A rather crazy idea which I would not recommend at all is to redefine the identity function at the top of the worksheet

Don't comment on the readibility of that worksheet 😉

1.png

Translate
23-Emerald V
Oct 3, 2014 10:55 AM UTC

Werner Exinger wrote:

A rather crazy idea which I would not recommend at all is to redefine the identity function at the top of the worksheet

Don't comment on the readibility of that worksheet 😉

1.png

Sneaky. I like it, Werner..

Stuart

... until he wants to really define an identity 3, but then I suppose it would be easy enough to define identity3:=identity(3) before redefining identity or even use a difference math style for identity(3).

Translate
11-Garnet
Oct 6, 2014 7:52 AM UTC

@^T [StuartBruff, Werner Exinger, Mike Armstrong]

Thanks for the great feedback. I liked the idea of Werner too, though admittedly it is not a good practice. But this comes from my initial bad design. I am still using MC v.11, so xml is not the standard format.

@Mike: I could uploaded my file, but in the essence I wanted to know how to handle a very simple case, like the one posted by Werner's image.

Thanks again.

Translate