필터 지우기
필터 지우기

Plotting a equally distributed quantized signal

조회 수: 2 (최근 30일)
S.M. Masudur Rahman
S.M. Masudur Rahman 2021년 7월 3일
댓글: Yazan 2021년 7월 3일
In MATLAB, quantize the following composite signal in 8 equally distributed levels and show only 4 cycles.
x=91*sin(2*pi*369*t)+36*sin(2*pi*919*t+pi/3)+69*sin(2*pi*183*t+2*pi/3)

채택된 답변

Yazan
Yazan 2021년 7월 3일
% sinusoids in the signal
f1 = 369;
f2 = 919;
f3 = 183;
% max and min spectral components
fmax = max([f1, f2, f3]);
fmin = min([f1, f2, f3]);
% sampling freq = 10 times the largest spectral component
fs = 10*fmax;
% show 4 cycles
T = 1/fmin*4;
% time axis
t = 0:1/fs:T-1/fs;
% signal
x = 91*sin(2*pi*f1*t) + 36*sin(2*pi*f2*t+pi/3) + 69*sin(2*pi*f3*t+2*pi/3);
% plot signal
figure, plot(t, x, 'LineWidth', 1), hold on, grid minor
% 8 levels of quantization
ql = 8;
% find the levels
th = linspace(min(x), max(x), ql);
% quantize the signal
xdif = abs(x-th');
[idx, ~] = ind2sub(size(xdif), find(xdif == min(xdif)));
xq = th(idx);
% plot quantized signal
plot(t, xq, '--g', 'LineWidth', 1.5);
legend({'Original signal', 'Quantized signal'}, 'Location', 'best');
hold off
  댓글 수: 2
S.M. Masudur Rahman
S.M. Masudur Rahman 2021년 7월 3일
In the output, quantized signal is not showing.
Yazan
Yazan 2021년 7월 3일
This is because you're using an old version of Matlab. Replace line 23 with the following
xdif = abs(repmat(x, [ql,1])-repmat(th',[1, size(x,2)]));

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Spectral Measurements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by