I'm working on a radar project and I want Matlab to send commands and collect radar data remotely from the USB port of a Raspberry Pi 3 B+. My setup is as follows:

I have the radar connected to the Pi 3 through the USB port and I'm using the Raspberry Pi package on MATLAB to communicate with the radar remotely through the USB port. I was able to successfuly communicate with the radar and collect radar data, but the problem is that using the setup I mentioned, I was bounded by a limit for the amount of data I can collect from the radar. For example:

When the radar is connected to the computer directly through USB I had no limit on the number of chirps I can send or on the number of samples in each chirp. For example, if I wanted to have 64 samples/chirp, I can send the max number of chirps possible which is 24 chirps.

However, when the radar is connected to the Pi I had a limit on the frame data, such that if I want to have 64 samples/chirp, I can only send 21 chirps which is down by 3 chirps.

After doing some research and experiments, I came to a conclusion that the problem is mainly located in the wireless communication between the Pi and MATLAB and mostly in the function that opens the virtual port on MATLAB (serialdev) or in the function (read) that reads the data from the Pi. The reason I came to that conclusion is because I tried a C code to collect the data on the pi directly to see if the problem is in the USB communication between the radar and the pi, but after running the code on the pi it was able to collect all the data with no limit and no problem.

Also, the problem is not in the wireless transmission between the Pi and the computer because using an SSH connection between the Pi and the computer I run the same C code to collect the data and I was able to collect the data on the computer with no limit on the number of sample or chirps and it works totally fine.

So, can you please help me with this, and can you tell me what is the limit for the amount of data that can be collected using the function serialdev and the function read?

If you think my conclusion is wrong tell me what do you think about it.

  • I think you might need to show us some of the code if we're going to be able to help with this. At least the MATLAB portion in question. Maybe the C that worked. I'm also unclear on how you were running the C code? Was it run on the Pi and that MATLAB on the PC? Or was the C running on the PC and communicating with the Pi in place of the MATLAB?
    – Brick
    Jun 11, 2019 at 19:26
  • The C code was running on the Pi while MATLAB on the PC.
    – alrizk
    Jun 12, 2019 at 13:14
  • I don't think i can send the codes here, cause they are big.
    – alrizk
    Jun 12, 2019 at 13:30
  • Excepting a minimal example seems critical if you want help. It's unclear exactly how you're communicating between PC and Pi at this point, and that probably matters. It's also still unclear what code is running on each device when the error occurs vs. when it works, and why, given that you have some solution that appears to work, that is inadequate. I think some illustrative code would clear all of that up. Not all the code, just enough to show where the problem happens.
    – Brick
    Jun 12, 2019 at 13:34
  • Can I assume that you already set MathLab.SerialDev to max baud rate of 230400?
    – tlfong01
    Jun 13, 2019 at 1:27

1 Answer 1


You analysis shows that the PI is fast enough to transmit and receive the data.

The only conclusion left is that whatever you do in MATLAB is too slow. While the PI is not bad, it is no match for a somewhat recent PC.

So you may want to write the control program in a more efficient language, like C, or you can try to identify the parts that need the most time and convert only those. Depending on the structure and complexity of your program, one of these approaches might be easier than the other.

  • Yes exactly the Pi has the ability to transmit and receive the data when the communication is done only between the Pi and the radar. I'm stuck with MATLAB for now, i think the problem is mainly in the functions included in the Pi support backage in MATLAB, mainly the on responsible for opening the virtual serial port.
    – alrizk
    Jun 12, 2019 at 13:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.