Simulink to MAVLink communication for PX4 Autopilots

I’m trying to upload the firmware through the UAV Toolbox support package for PX4 autopilots. The initial Hardware Setup is completed. I’m using one of the MATLAB examples for the same toolbox package to upload my code into the PX4 flight controller.
The problem is that MATLAB is not detecting the “ProfiCNC CUBE F4 FMU (COM3)” port but detecting the “Legacy FMU (COM5)” port, which renders the system to show a message saying
“Attempting reboot on COM5 with baudrate=57600… If the board does not respond, unplug and re-plug the USB connector.”
I had faced the same problem with the initial “Hardware Setup” process, which I could overcome by simply rebooting the hardware just before the MATLAB firmware upload subprocess.
Now when I try to upload a customized Firmware based on one of the examples for the UAV toolbox, I’m not able to reboot the hardware since the hardware cannot be a reboot in the middle of the Simulink program. Please suggest a solution to the problem.