# Subscript in macro

I would like to define a new command like the following. The latex when compiling should emit I_{wr} when given without arguments, or the optional arguments should come as a subscript.

\newcommand{\myCommand}[1][]{I_{wr#1}}


So If I give $\myCommand{2}$, then it would emit the text as I_{wr}2. The 2 does not come in the subscript form. Could anyone please tell me how to do this correctly?

Thank You

-

It's already correct except for the usage:

\newcommand{\myCommand}[1][]{I_{wr#1}}


The argument is an optional argument that uses square brackets:

$\myCommand[2]$


Full example:

\documentclass{article}

\newcommand{\myCommand}[1][]{I_{wr#1}}

\begin{document}
$\myCommand[2] = 2 * \myCommand$
\end{document}


-