Is there a function or a way to write/read bit by bit to/from a buffer in MATLAB?
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
An Vo
el 13 de Dic. de 2021
Comentada: jibrahim
el 14 de Dic. de 2021
Hi everyone, I am testing an audio compression in Matlab, and I am searching a way to write/read bit by bit to/from a buffer in MATLAB.
For example, I have a sequence of bits: 100, so I need to write in order bit 0, bit 0 and then bit 1 to the buffer. For the next sequence for example 1011, I need to write in order bit 1, bit 1, bit 0 and then bit 1 next to the first sequence into the buffer.
My goal is to write many sequences of bits to a buffer and read those sequences back for process, and they need to be in bit by bit.
Thank you so much for your help and support,
Best regards,
Le An.
0 comentarios
Respuesta aceptada
jibrahim
el 13 de Dic. de 2021
Hi An,
Maybe dsp.AsyncBuffer works for you?
b = dsp.AsyncBuffer;
write(b,1); % write the number 1 to the buffer
write(b,2); % write 2 to buffer
write(b,3); % write 3 to buffer
read(b,1) % read one element --> 1
write(b,4); % write 4 to buffer
read(b,1) % read one element --> 2
read(b,1) % read one element --> 3
b = dsp.AsyncBuffer;
write(b,1); % write the number 1 to the buffer
write(b,2); % write 2 to buffer
write(b,3); % write 3 to buffer
read(b) % read everything [1 2 3].'
2 comentarios
jibrahim
el 14 de Dic. de 2021
Hi An,
To check how many samples are available in the buffer, you can execute:
b.NumUnreadSamples
Más respuestas (0)
Ver también
Categorías
Más información sobre Code Generation and Deployment en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!