What is happening in the Example "Channelize and Synthesize Sine Wave in MATLAB"?

1 view (last 30 days)
In the Example "Channelize and Synthesize Sine Wave in MATLAB" - in the part "Streaming" we have a loop:
for i = 1:5000
x = sum(sinewave(),2);
y = channelizer(x);
v = synthesizer(y);
spectrumAnalyzer(x,v)
end
  1. Why is that loop necessary?
  2. What is the index i?
  3. Why the index i has the range 1:5000, why 5000 when everything else has the length 8000?
  4. Can we do the same without the loop? (vectorize)
  2 Comments
Anna
Anna on 24 Apr 2023
Someone from Mathworks Staff answered these questions but when I asked for more details and pointed out the errors in the answers then the Someone simply deleted our whole conversation today (24.04.2023)

Sign in to comment.

Answers (1)

Pranjal
Pranjal on 24 Apr 2023
The loop in the example "Channelize and Synthesize Sine Wave in MATLAB" is used to stream data through the channelizer and synthesizer in real-time. The loop processes 5000 samples of data each iteration, and the spectrumAnalyzer() function is used to visualize the frequency spectrum of the input and output signals.
The index i is used to keep track of the loop iteration number. It is not used in any calculations within the loop, but it could be used for other purposes such as timing the loop or logging data.
The loop has a range of 1:5000 because each iteration processes 5000 samples of data. The input and output signals are both 8000 samples long, but they are processed in smaller chunks to simulate real-time processing.
It is possible to process the entire input signal without using a loop by passing the entire signal to the channelizer and synthesizer functions at once. However, this would not simulate real-time processing and may not be practical for larger input signals.
  1 Comment
Anna
Anna on 25 Apr 2023
Thank you for your reply.
  1. You wrote: "The loop processes 5000 samples of data each iteration" . Where in the code you see that the signal in divided into chunks of 5000 samples? How to change it to 1000 samples per chunk? Or 300 samples per chunk?
  2. You wrote: "The loop has a range of 1:5000 because each iteration processes 5000 samples of data." - No, the index i = 1:5000 it means that the loop is repeated 5000 times.
  3. At the end, the elements x and v have size 800x1. How to change it to 1000x1 or other?
  4. You wrote: "It is possible to process the entire input signal without using a loop by passing the entire signal to the channelizer and synthesizer functions at once. " - this is what I am looking for. Could you please point me an example of a channelizer without the loop? Or please tell me how to change the code to pass the whole signal at once.

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!