フィルターのクリア

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 Center および File ExchangeSpectral Measurements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by