In the attached file i charge a capacitor when voltage is applied and decharge when 0V is applied by the help of an and gate(for simulation). What i want to do is capacitor will charge the same way ; but when 0 volts come i do not want its voltage to drop down but rather i want it to stay steady at its reached level like the yellow line in the picture i drew in paint.... How can this be possible?