EDIT If you're using GNU Radio 3.7 (and have
good reason not to use any more recent release, which you really should!): Please don't use selector. It's "stop everything, reconnect blocks internally, continue everything" has terrible side effects.
If you're using GNU Radio 3.8.0.0 or later: We've replaced the above mechanism by a simple point-to-point copy, which is way more robust (but comes at a copying overhead). So, starting with 3.8-techpreview, selector is safe to use.
Try the "Selector" block. You can set the active in/output ports with two variables.
Internally, selector is a hierarchical block, and it will pause your flowgraph, disconnect the formerly active in- and output blocks connect the now active blocks, and then continue operation of the flow graph.
In that manner, it's not sample-accurate, and might not be the tool of choice. You might want to look into message passing instead of using variables, and go for the "Multiply (with) Matrix" block.