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)
What is happening in the Example "Channelize and Synthesize Sine Wave in MATLAB"?
1 view (last 30 days)
Show older comments
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
- Why is that loop necessary?
- What is the index i?
- Why the index i has the range 1:5000, why 5000 when everything else has the length 8000?
- Can we do the same without the loop? (vectorize)
2 Comments
Answers (1)
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.
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!