Square wave generator similar to dsp.SineWave

조회 수: 10 (최근 30일)
masnoob 2019년 1월 8일
댓글: masnoob 2019년 1월 10일
I know squarewave() function, but I would like to know is there an equivalent system object square wave generator, just like dsp.SineWave so I can generate 1024 samples per loop for demodulation purposes in streaming processing of audio signals.
Thanks
댓글 수: 2없음 표시없음 숨기기
Walter Roberson 2019년 1월 8일
is this for use in simulink ? if so the repeating pattern generator can be used.
masnoob 2019년 1월 8일
편집: masnoob 2019년 1월 8일
I actually have implemented stream processing where the entire process is real time based, contained within a while loop, currently using sine wave but I just want to produce square wave instead in matlab, not simulink.

댓글을 달려면 로그인하십시오.

채택된 답변

Gabriele Bunkheila 2019년 1월 9일
Please take a look at audioOscillator in Audio System Toolbox, which can generate sine, square, and sawtooth waveforms.
댓글 수: 3이전 댓글 1개 표시이전 댓글 1개 숨기기
Gabriele Bunkheila 2019년 1월 9일
편집: Gabriele Bunkheila 2019년 1월 9일
Glad to hear that helped!
As for visualizing the response of graphicEQ, if the visualize() doesn't work for you, then you may want to use coeffs() to extract the filter coefficients and then plot the response using a standard approach, such as the following:
% Create and configure the equalizer
g = graphicEQ;
g.Gains = 6*randn(size(g.Gains)); % random gains in dB
% Extract the coefficients
[B,A] = coeffs(g);
% Compute the response using the SOS argument format for coefficients
[h,f] = freqz([B;ones(1,size(B,2));A]',4096,g.SampleRate);
% Plot magnitude over frequency and customize appearance
hp = plot(f,db(abs(h)));
hp.Parent.XScale = 'log';
hp.Parent.XLim = [20, 20e3];
xlabel('Frequency (Hz)')
ylabel('Response (dB)')
grid('on')
masnoob 2019년 1월 10일
Thanks Gabriele! the solution worked like a charm!

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Signal Generation, Manipulation, and Analysis에 대해 자세히 알아보기

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by