Optical and electrical measurements at the nanoscale