Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I have generated a matrix using Mathematica,

$\left( \begin{array}{ccc} \text{cos$\theta $} & -\text{sin$\theta $} & \text{cos$\theta $}\, \text{dx}+\text{dx}-\text{dy}\, \text{sin$\theta $} \\ \text{sin$\theta $} & \text{cos$\theta $} & \text{cos$\theta $} \,\text{dy}+\text{dy}+\text{dx}\, \text{sin$\theta $} \\ 0 & 0 & 1 \\ \end{array} \right)$

Now I want to change the variable names $dx$ to $xr$ and $dy$ to $yr$. How could I do this?

share|improve this question
add comment

1 Answer 1

up vote 5 down vote accepted

You can do it programmatically using Replace. For example:

{{1, 1, 1}, {1, dx, x^2}, {1, dy, du^2}} /. {dx -> s, dy -> "hello"}

replaces the dx with s and the dy with "hello". You can choose your own replacements. To understand what this actually means, consider the longer form:

Replace[{{1, 1, 1}, {1, dx, x^2}, {1, dy, du^2}}, {dx -> s, dy -> "hello"}, 2]

which shows that you want to replace the specified items in the second level (the "2") of the matrix.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.