NXT encoder, Arduino and Matlab to control motor rotation

I am trying to work with my students taking a process control lab to utilize an Arduino Uno, Matlab and Lego NXT motors to open/close valves to control water height in a tank.

the NXT motor is equipped with a quadrapole encoder but students are having a difficult time to get it to run properly.

Using Matlab 2017 that has encoder library.

most blogs on the subject are dated (pre 2014) and thus not useful.

any guidance/suggestions are greatly appreciated.
Greg Ogden

Hi,

Did you take a look at this video ? At 15:00, he explains how to control Lego NXT Motors with Matlab.
Here is also the RWTH - Mindstorms NXT Matlab Toolbox to control Lego Mindstorm NXT robots that might help you.