getting data from an array correctly
Mostrar comentarios más antiguos
Hi, I have the following data that I get it from the socket
header = [53 0 1 2 3 4 5 6 7 8 9 53 1 24 59 5 95 95 53 2 59 58 575 75 53 0 1 4 2 4 9 1];
The header first starts with 53, then maybe 0 or 1 or 2. so I need to get the bytes after 53 + 0 till the next 53 ( in between) and also get the data after 53 + 1 till the next 53 and so on
I tried that but it crashes
header = [53 0 1 2 3 4 5 6 7 8 9 53 1 24 59 5 95 95 53 2 59 58 575 75 53 0];
where = find(header == 53);
if numel(where) > 1 && header(where(1)+1) == 1 % check if there are more then 1 53s and number after first 53 is 0.
nextbytes = header(where(1)+2:where(2)-1);
disp(nextbytes);
end
4 comentarios
Walter Roberson
el 24 de Mayo de 2018
If the data itself included a 53, then how would that be coded?
What do you want to do in the case of a 53 followed by something that is not a 0, 1, or 2 ?
Ahmed Tolba
el 24 de Mayo de 2018
dpb
el 24 de Mayo de 2018
Is it possibly data, though, even if not new record marker?
A formal description of the protocol would be more beneficial, methinks.
Ahmed Tolba
el 24 de Mayo de 2018
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre MATLAB en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!