  We consider a cognitive radio system, in which the secondary users (SUs) and
primary users (PUs) coexist. The SUs are equipped with steerable directional
antennas. In our system, the secondary transmitter (SUtx) first senses the
spectrum (with errors) for a duration of {\tau}, and, then transmits data to
the secondary receiver (SUrx) if spectrum is sensed idle. The sensing time as
well as the orientation of SUtx's antenna affect the accuracy of spectrum
sensing and yield a trade-off between spectrum sensing and capacity of the
secondary network. We formulate the ergodic capacity of secondary network which
uses energy detection for spectrum sensing. We obtain optimal SUtx transmit
power, the optimal sensing time {\tau} and the optimal directions of SUtx
transmit antenna and SUrx receive antenna by maximizing the ergodic capacity,
subject to peak transmit power and outage interference probability constraints.
Our simulation results show the effectiveness of these optimizations to
increase the ergodic capacity of the secondary network.
