[Tex/LaTex] Referencing subfigures in main caption (with \subfloat and \subref)

cross-referencingsubcaptionsubfloats

I've used subfloat to include subfigures, with their relevant labels but with empty captions. what I'm going to do is to reference these figures with \subref in the main caption of the figure. But what I get is only ?? signs in the caption [main caption]. I can't figure out what's the problem. this is what I have:

\begin{figure}
\centering
\subfloat[][]
{
\includegraphics[scale=0.55]{signal}
\label{signal_model}
}
\subfloat[][]
{
\includegraphics[scale=0.55]{amplitude}
\label{amplitude_mod}
}
\caption{phase noise variability: \subref{signal model} some text \subref{amplitude_mod} some other text}
\end{figure}

Best Answer

You need to \protect the \subref command in the caption:

\caption{Phase noise variability: \protect\subref{signal_model} some text 
  \protect\subref{amplitude_mod} some other text}

MWE:

\documentclass{article}
\usepackage{graphicx}
\usepackage{subfig}
\begin{document}

\begin{figure}
\centering

\subfloat[][]{\includegraphics[scale=0.55]{example-image-a}\label{signal_model}}
\subfloat[][]{\includegraphics[scale=0.55]{example-image-b}\label{amplitude_mod}}

\caption{Phase noise variability: \protect\subref{signal_model} some text 
  \protect\subref{amplitude_mod} some other text}

\end{figure}
\end{document}

enter image description here