interacting with Matlab and still using the serial monitor

I'm working on a control problem, using an Arduino Mega2560 as a real time controller and Matlab as a supervisor. Matlab provides the coefficients for the control law, which it calculates from results returned by Arduino.

The Arduino is working flat out in a control loop, but sending results to Matlab only every 10s or so. It then waits for a ms or two until it receives a new string of integer numbers to use in its control.

I've got a prototype working, but debugging has been difficult because I cannot see how to use the serial monitor when the COM port is tied up for communication with Matlab.

Has anybody any suggestions on how this can be overcome? Is it possible either to use two COM ports at the same time, or to use the one for both purposes?

I cannot see how to use the serial monitor when the COM port is tied up for communication with Matlab.

You can't.

Has anybody any suggestions on how this can be overcome?

Matlab can read, and display, serial data. Why not use that capability to debug your code?

Is it possible either to use two COM ports at the same time

On the PC? Yes. On the Arduino, only one of the hardware serial ports is connected to the USB cable that goes to the PC. You are talking to Matlab on that port.

You could use an LCD to display a small amount of data, or an FTDI cable to connect one of the other hardware serial ports to a USB cable. Then, you would use a different serial application, like PuTTY or RealTerm, to be able to connect to the port of your choosing (assuming that you choose to connect to the port that the FTDI cable is connected to).