I have some problem with the counter of my figures. I added several figures, some of them with captions and some of them without captions. I want those figures with captions to be counted, the others should not increase the counter. Somehow it sometimes work, sometimes it does not.
For example, apparently the following figure is being counted (since when I erase it, the following figures' counters are decreased by one):
\documentclass{article}
\usepackage{amsmath,amssymb}
\usepackage{amsthm}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{chngcntr}
\usepackage{framed}
\usepackage{tikz}
\usepackage{geometry}
\usetikzlibrary{fit,matrix}
\counterwithin{figure}{section}
\begin{document}
\begin{figure}[h]
\begin{subfigure}[h]{0.3\textwidth}
\centering
\(u=\)
\tikz[baseline=(M.west)]{%
\node[matrix of math nodes,matrix anchor=west, ampersand replacement=\&] (M) {%
~3 \& 0 \&~ 0 \&~ 0\\
~-3 \& 0 \&~ 0 \&~ 0\\
~0 \& 0 \&~ 0 \&~ 0\\
};
\node[draw,fit=(M-1-1)(M-3-4),inner sep=-1pt] {};
},
\end{subfigure}%
~
\begin{subfigure}[h]{0.215\textwidth}
\centering
\(v=\)
\tikz[baseline=(M.west)]{%
\node[matrix of math nodes,matrix anchor=west, ampersand replacement=\&] (M) {%
~3 \& 0 \&~ 0 \&~ 0\\
~0 \& 0 \&~ 0 \&~ 0\\
~-3 \& 0 \&~ 0 \&~ 0\\
};
\node[draw,fit=(M-1-1)(M-3-4),inner sep=-1pt] {};
}
\end{subfigure}
\end{figure}
\end{document}
I guess the figure looks weird to some of you, I am not very good at writing Latex documents. But the main problem is the numbering for now.
Does the counter depend on the size of the figure?
Can I manually tell the program to skip counting a specific figure?

\captionis used (the unstarred version) – Jul 05 '15 at 17:34\begin{figure} ... \caption{...} \end{figure}\label{figure3.1} ... \begin{figure} ... \end{figure} ... \begin{figure} ... \caption{...} \end{figure}\label{figure3.2}– lattice Jul 05 '15 at 17:43\labelshould be after\captioninside thefigureenvironment. – Werner Jul 05 '15 at 17:48\caption. Now the references work correctly, but the figure numbering has not changed. – lattice Jul 05 '15 at 17:59\captionshould not increase the counter. We need to know what document class you are using. – egreg Jul 05 '15 at 18:06figure(unless you have redefined it) does not use the counter at all, only\captionincrements the counter. – David Carlisle Jul 05 '15 at 18:07articleclass figures do not increment any counter. Please always post a complete small document that shows the problem. Oh but you (now) show subfigure which redefines the numbering scheme so that changes the problem completely. But the example can not be run please compete it with\documentclass\end{document}etc and check that the code as posted produces bad numbering. – David Carlisle Jul 05 '15 at 19:14\setcounter{figure}{number}but I do not really like this method. – lattice Jul 05 '15 at 19:30