I'm not sure it is what you are looking for, but have you had a look at CodeRunner? With that question type you can use variables, randomise questions, evaluate answers (code in various programming languages including Octave, which is very similar to MatLab). I'm not sure about graphical representations, though.
We are currently using it on Moodle 3.6, but it is also available for 3.7 and 3.8, and is actively maintained.
Edit: Check also here for wiris moodle plugins - they offer a variety of question types.
Hope this helps!