Why is this block of code giving me an "Undefined function for input arguments of type" error?

2 views (last 30 days)
I'm working on a project and I can't figure out why in this block of code I'm getting "Undefined function 'transf_response_plotter' for input arguments of type string". What the code does is that it looks at the difference in frequency responses between H(z) and H(A(z)) where A(z) is an all pass filter and H(z) is an elliptic low pass filter. Attached below is the code that's producing the error along with the functions it calls:
%these are the coefficients of the numerator and denominator of the all
%pass filter
all_num = [1 -0.3];
all_denom = [0.3 -1];
%plot the magnitude response of H(A(z)) and H(z) (this is the function
%that's causing the error
transf_repsonse_plotter(all_num, all_denom, "PART A");
%plots the magnitude response of H(z) which is a lowpass filter
%and then also plots the magnitude response of H(A(z)) where A(z)
%is an all pass filter
%takes in the numerator and denominator coefficients of the all pass
%filter as well a string variable part which is used for labeling the plot
function plt = transf_response_plotter(tran_num, tran_denom, part)
%get the magnitude response of H(z) by calling on the transform
%function and composing it with z
filt_response = transform([1 0], 1);
%get the magnitude response of H(A(z))
transform_response = transform(tran_num, tran_denom);
%set up the x axis of the plot, the frequency values that we used to sample
%the magnitude response
w = linspace(-1*pi, pi, 1000);
%and then plot each of the responses
figure;
plot(w, transform_response);
hold on;
plot(w, filt_response);
hold off;
legend("Transformed Response", "Original Response");
xlabel("Analog Radian Frequency (2pi)");
ylabel("Magnitude dB");
title(sprintf("%s: Effect of Allpass Transformation on Magnitude Response of Low Pass Elliptic Filter", part));
plt = 0;
end
%this function computes the magnitude response of H(A(z))
%where A(z) is an all pass filter and H(z) is a low pass filter
%takes in tran_num, the numerator coefficients of A(z) and
%tran_denom, the denominator coefficients of A(z)
function tran_filt_response = transform(tran_num, tran_denom)
%get the numerator and denominator coefficients of H(z), the lowpass
%filter
[num, denom] = ellip(12, 2, 30, 0.25);
%set up a range of frequencies which we will use to sample the
%magnitude response with
w = linspace(-1*pi, pi, 1000);
%use polyval to evaluate A(z) at e^jw
tran_response = polyval(tran_num, exp(1j*w))./polyval(tran_denom, exp(1j*w));
%and then take that output and evaluate H(z) at A(e^jw)
%then take the magnitude of the response and convert it to dB
tran_filt_response = 20*log10(abs(polyval(num, tran_response)./polyval(denom, tran_response)));
end

Accepted Answer

DGM
DGM on 20 Oct 2022
Sometimes it's the little things that get ya ...
transf_repsonse_plotter()

More Answers (0)

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!