Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

MATLAB real time serial data plot

Status
Not open for further replies.

dmta

Member
Hi all,

I am trying to use this code to plot the serial data comming from my serial port

But I am having this error

??? In an assignment A(I) = B, the number of elements in B and
I must be the same.

Error in ==> real_time_data_serial at 80
voltage(count) = fscanf(s,'%f');

What should I do ?

Regards
 
There are most likely multiple numbers coming in the serial port, and therefore fscanf will return an array of values.

Code:
>> s = '455.54 55.5'

s =

455.54 55.5

>> data(1) = sscanf(s, '%f')
In an assignment  A(I) = B, the number of elements in B and I
must be the same.
 
>> data = sscanf(s, '%f')

data =

  455.5400
   55.5000

I'm using sscanf on a string rather than fscanf on a serial port, but I would assume the result to be the same
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top