As the following link mentions, you should start MATLAB after you have connected your MIDI device:
Verify that MATLAB is able to identify the connected MIDI controller when you execute "midiid" in MATLAB Command Window. When you call "midiid" MATLAB waits for a Control Change message from your MIDI Device. When you use a control on your MIDI Board, MATLAB recieves a Control Change message and it returns a control number corresponding to the MIDI controller number that you interacted with on your MIDI hardware. The following link describes how MATLAB defines control numbers:
Note that 'midiid' and associated MIDI functions are for use with MIDI control surfaces and only respond to MIDI Control Change messages. The keyboard sends other kinds of messages (Note On, etc). Please refer to the MIDI implementation of your device's Manual to verify what knobs, sliders, pedals etc. can send Control Changes messages which would be recognized by 'midiid'.
Also, the keyboard may have to be in a particular mode for the controls to work. MIDI Monitor is probably the best way to figure out what the keyboard is sending. If it is sending Control Change messages, 'midiid' should be able to see them.
There are other failure modes. For example, two programs cannot share a MIDI device. If another program (e.g., MIDI Monitor) is still connected to the keyboard, MATLAB will not be able to find it.
There is also a File Excange submission you could look into. As the author mentions, this only works on Windows XP and later:
Here are some other tools from the community that are available for you to try: