Vectors must be the same length
Ältere Kommentare anzeigen
fs = 100 % Örnekleme frekansı fs
Ts = 1/fs % Örnekleme periyodu Ts
fu = 5 % Oluşturacağımız sinyalin frekansı (fs/2'den küçük olmalı!)
t = 0:Ts:5/fu; % Zaman vektörü
u = sin(2*pi*fu*t); % Frekansı fu olan sinüs
subplot(2,1,1)
plot(t,u,'LineWidth',2);
title(['5 Hz lik sinüs sinyali']);
ylabel('Genlik');
xlabel('Zaman (s)');
grid;
Ws = 2*pi*fs % Radyan cinsinden örnekleme frekansı = Ws
Ts = 1/fs % Ts = 0.01 saniye
N = 128 % Derece N
fc = 20 % Kesim frekansı fc
Wc = 2*pi*fc % Radyan cinsinden kesim frekansı = Wc
Wn = Wc/(Ws/2) % Wc'nin Ws/2'ye göre normalize edilmişi
y = fir1(N,Wn,"low");
subplot(2,1,2)
plot(t,u,t,y,'LineWidth',1.5);
grid;
title('Giriş ve filtrelenmiş çıkış');
xlabel('t (s)');
ylabel('Genlik');
legend('100 Hz sinüs giriş','Çıkış');
######onCommand Window
Error using plot
Vectors must be the same length.
Error in untitled4 (line 20)
plot(t,u,t,y,'LineWidth',1.5);
Antworten (1)
Torsten
am 30 Apr. 2022
0 Stimmen
y has more or less elements than t. That's why MATLAB does not know how to plot y against t.
3 Kommentare
N = numel(t)-1; % Derece N
instead of
N = 128 % Derece N
But I doubt that you want to plot filter coeffcients against time.
Torsten
am 30 Apr. 2022
And ? Does it work with the correction ?
For me, the code works:
fs = 100 % Örnekleme frekansı fs
Ts = 1/fs % Örnekleme periyodu Ts
fu = 5 % Oluşturacağımız sinyalin frekansı (fs/2'den küçük olmalı!)
t = 0:Ts:5/fu; % Zaman vektörü
u = sin(2*pi*fu*t); % Frekansı fu olan sinüs
subplot(2,1,1)
plot(t,u,'LineWidth',2);
title(['5 Hz lik sinüs sinyali']);
ylabel('Genlik');
xlabel('Zaman (s)');
grid;
Ws = 2*pi*fs % Radyan cinsinden örnekleme frekansı = Ws
Ts = 1/fs % Ts = 0.01 saniye
N = numel(t)-1;%128 % Derece N
fc = 20 % Kesim frekansı fc
Wc = 2*pi*fc % Radyan cinsinden kesim frekansı = Wc
Wn = Wc/(Ws/2) % Wc'nin Ws/2'ye göre normalize edilmişi
y = fir1(N,Wn,"low");
subplot(2,1,2)
plot(t,u,t,y,'LineWidth',1.5);
grid;
title('Giriş ve filtrelenmiş çıkış');
xlabel('t (s)');
ylabel('Genlik');
legend('100 Hz sinüs giriş','Çıkış');
Kategorien
Mehr zu Title finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!