3
$\begingroup$

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?

$\endgroup$
5
$\begingroup$

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.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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