Serial Communication with Matlab

Discussion in 'Programmer's Corner' started by Dammi, Mar 2, 2011.

  1. Dammi

    Thread Starter New Member

    Feb 15, 2011
    16
    0
    Hi guys

    I was wondering, how do I make Matlab stop reading from a serialport ?

    I have this:

    s = serial('COM2');
    set(s,'BaudRate',9600);
    set(s,'DataBits',8);
    set(s,'StopBits',1);
    fopen(s);
    av = fscanf(s);

    And I get the data I want, I just want Matlab to stop reading from the port when the data has been sent, cause I'll be sending the data again after that, so how would I do that?

    In other words, how do I tell Matlab to stop/start reading when a certain char has been sent? I see when I enable the serial communication taht "Terminator is 'LF'" .. so should I send 'LF' from the MC to let matlab stop ?

    Help plz :)
     
  2. mbabayan

    Member

    Jul 12, 2010
    30
    1
  3. Dammi

    Thread Starter New Member

    Feb 15, 2011
    16
    0
    I used fread instead, wasn't able to use the LF character function, but it's okay, we worked around it :)
     
Loading...