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.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…