  We address the problem of designing a stabilizing closed-loop control law
directly from input and state measurements collected in an open-loop
experiment. In the presence of noise in data, we have that a set of dynamics
could have generated the collected data and we need the designed controller to
stabilize such set of data-consistent dynamics robustly. For this problem of
data-driven control with noisy data, we advocate the use of a popular tool from
robust control, Petersen's lemma. In the cases of data generated by linear and
polynomial systems, we conveniently express the uncertainty captured in the set
of data-consistent dynamics through a matrix ellipsoid, and we show that a
specific form of this matrix ellipsoid makes it possible to apply Petersen's
lemma to all of the mentioned cases. In this way, we obtain necessary and
sufficient conditions for data-driven stabilization of linear systems through a
linear matrix inequality. The matrix ellipsoid representation enables insights
and interpretations of the designed control laws. In the same way, we also
obtain sufficient conditions for data-driven stabilization of polynomial
systems through (convex) sum-of-squares programs. The findings are illustrated
numerically.
