How can you separate incoming serial data?
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have incoming serial data from an Arduino board that update continuously. The data is separated by questions marks (?). How would I go about reading the data in MATLAB and separating it into a (12x1) column vector so I can call an index of that vector? I have tried fscanf() but have been unable to get the results I want.
From Arduino:
152?-9?215?-669?2541?1273?-141?27?-452?20.30?97242.00?345.62? ect
delete(instrfind)
s=serial('COM4','BaudRate',9600); %start serial port to arduino
s.ReadAsyncMode = 'continuous';
fopen(s); %open port
while (s.Status == 'open')
C=fscanf(s, '?');
C
if(s.Status ~= 'open')
break;
end
end
0 commentaires
Réponse acceptée
Matthias
le 20 Avr 2013
I don't have an Arduino, so I couldn't test it. But how about that:
c_str=regexp(C,'?','split');
1 commentaire
alex korzaniewski
le 20 Avr 2013
Modifié(e) : alex korzaniewski
le 20 Avr 2013
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur MATLAB Support Package for Arduino Hardware dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!