Read data from the async buffer without changing the number of unread samples using the peek
function.
Create a dsp.AsyncBuffer
System object™. The input is a column vector of 100 samples, 1 to 100. Write the data to the buffer.
asyncBuff =
AsyncBuffer with properties:
Capacity: 192000
NumUnreadSamples: 0
Peek at the first three samples. The output is [1 2 3]'.
The NumUnreadSamples
is 100, indicating that the peek
function has not changed the number of unread samples in the buffer.
After peeking, read 50 samples using the read
function. The output is [1:50]'.
out2 = 50×1
1
2
3
4
5
6
7
8
9
10
⋮
The NumUnreadSamples
is 50, indicating that the read
function has changed the number of unread samples in the buffer.
Now peek again at the first three samples. The output is [51 52 53]'. Verify that the NumUnreadSamples
is still 50.
Read 50 samples again. The output now contains the sequence [51:100]'. Verify that NumUnreadSamples
is 0.
out4 = 50×1
51
52
53
54
55
56
57
58
59
60
⋮