Switching periodic membranes via pattern transformation and shape memory effect