# ovals in tabular

Need ovals in the tab:

\documentclass[9pt,handout,compress,rgb]{beamer}
\usepackage{amstext}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{tikz}

\begin{document}
\begin{frame}

\begin{center}
\begin{tabular}{c|ccc}
& $M_1$ & \cdots & $M_n$\\
\hline\\
$W_1$  &   &   & \\
\vdots & & \ddots  &  \\
$W_m$ &   &  &
\end{tabular}
\end{center}
\end{frame}
\end{document}


I want the following (with narrower ovals):

Here is a possibility using nicematrix and TikZ with libraries fit (for fit) and shapes.geometric (for elliptical nodes). You can adjust the ellipses by changing minimum size= in myellipse.

Remember to compile twice when using nicematrix.

\documentclass[9pt,handout,compress,rgb]{beamer}
\usepackage{amstext}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{tikz}
\usetikzlibrary{fit, shapes.geometric}
\usepackage{nicematrix}
\tikzset{myellipse/.style={draw, red, very thick, ellipse, fit=#1, minimum size=3mm, inner sep=0pt}}

\begin{document}
\begin{frame}
$\begin{NiceArray}{c|ccc} & M_1 & \cdots & M_n\\ \hline\\ W_1 & & & \\ \vdots & & \ddots & \\ W_m & & & \CodeAfter \begin{tikzpicture} \node[myellipse=(3-|2.5)(5.5-|2.5)] {}; \node[myellipse=(3-|4.5)(5.5-|4.5)] {}; \node[myellipse=(3.5-|2.5)(3.5-|4.5)] {}; \node[myellipse=(5.5-|2.5)(5.5-|4.5)] {}; \end{tikzpicture} \end{NiceArray}$
\end{frame}
\end{document}