Borrar filtros
Borrar filtros

transmission zeros and poles

8 visualizaciones (últimos 30 días)
Kamil Tkacz
Kamil Tkacz el 4 de Feb. de 2015
Respondida: Niranjan Sundararajan el 7 de Jun. de 2023
Hi i have a problem with my matlab codes. I would be very gratefull if someone show me where i did mistake. Matlab shows error:
"Error using horzcat
Dimensions of matrices being concatenated are not consistent.
Error in bvcbvcbc (line 15)
x=[zeros(l),1]"
and my matlab code:
clear all;
close all;
clc;
w0=pi/4;
N=15;
z=exp(1i*w0);
n=[-N:1:N];
z0=0.9*exp(1i*w0);
p = poly([z0,conj(z0)])
[H,w]=freqz(1,p,1e3);
figure()
plot(w/pi,abs(H))
grid on
l=length(n)-1;
x=[zeros(l),1]
imp=filter(p,x,[H,w]);
plot(n,imp)
plot should looks like this:

Respuestas (1)

Niranjan Sundararajan
Niranjan Sundararajan el 7 de Jun. de 2023
Hey there,
I believe you are getting an error since you are trying to horizontally concatenate a square matrix ( zeros(k) will generate a square matrix of size k x k ) with 1. That will give you a dimensionality error, the one which you are getting. In order to solve this problem, try to use the following code.
l = 10; % for example
x=[1 zeros(1, l)]; % [1 0 0 0 ... 0 0 0]
% or
x=[zeros(1, l) 1]; % [0 0 0 ... 0 0 0 1]
I tried both ways, and what I believe you are trying to plot is the impulse response of a digital filter designed using the Z-transform, where the filter coefficients are obtained from the roots of a polynomial. I got better answers using the first method to generate the responses (the link to view the required response has expired).
Over and above this, you need to use the 1-D filter command in the following way:
p = [1 1 1]; % for example
imp=filter(1, p, x);
You may refer to the documentation links for the filter function from here. In case the required response is different, it would help you solve this question further.
All of this used together, your output would look like this:
clear all;
close all;
clc;
w0=pi/4;
N=15;
z=exp(1i*w0);
n=-N:1:N;
z0=0.9*exp(1i*w0);
p = poly([z0,conj(z0)]);
[H,w]=freqz(1,p,1e3);
figure()
plot(w/pi,abs(H))
grid on
l=length(n)-1;
x=[1 zeros(1, l)];
imp=filter(1, p, x);
plot(n,imp)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by