Matlab Serial Port

Matlab has a 'serial' function that allows it to communicate through a serial port. This project is to establish serial port connection with the PIC microcontroller and demonstrate bidirectional communication between the PIC and a Matlab program. In the serial port context, 9600 baud means that the serial port is capable of transferring a maximum of 9600 bits per second. If the information unit is one baud. Mar 04, 2015  Serial port is most common way of communication, we can send or receive data using serial port. Normally, in engineering projects there’s a need to send or receive data from microcontrollers to computer and in such projects, we used serial communication as its easy and quite quick in communication. Send data to Serial Port in MATLAB. Hi guys I am new to matlab. I would like to read data output from arduino through serial port. The data is output at certain time interval with comma/ space separating the variables. How I read the. We have discussed serial port many times and have seen how to communicate with it using different software but we haven’t yet discussed how to send data to serial port in MATLAB. So, in today’s post I am gonna share the complete code for sending data to serial port in MATLAB.

Active1 year, 6 months ago

Hi guys I am new to matlab. I would like to read data output from arduino through serial port. The data is output at certain time interval with comma/ space separating the variables. How I read the data and plot the variable on Matlab?

The serial port is like this:

1.1 3.2

1.2 3.1

1.3 3.3...

Matlab

Thanks for your help.

This is the code I got for reading data of only one variable without any space. How to modify that to read data of more than one variable?

I tried this one but seems not working.

Hon Lam Franco Chan
Hon Lam Franco ChanHon Lam Franco Chan

1 Answer

You need to change the point where you get the data from your arduino. This line in your code:

There it gets the data from your serial object s. You could change it into this:

Now you have dist as a variable with two numbers in it. To put them in two seperate variables you could do this:

To put them into your plot you now require two lines, so your distance variable starts as

And to put them in your graph you use

Serial

Matlab Serial Port Read

GelliantGelliant

Matlab Serial Port Timestamp

1,5981 gold badge5 silver badges20 bronze badges

Matlab Open Com Port

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