简体   繁体   中英

Wolfram Alpha and MATLAB plot transfer function differently

I am trying to get the filter coefficients for a digital IIR filter of a simple 180° phase shift allpass filter with the transfer function: (1+s)/(1-s)

This is what Wolfram gives me: Bode Plot in Wolfram

and this is what I get from MATLAB: Bode Plot in MATLAB

My code is:

clc; clear; close all;
z = [-1];                  %zeros
p = [1];                   %poles
k = 1;                     %gain
[num,den] = zp2tf(z,p,k);  %convert zero-pole into numerator denominator
freqz(num,den);            %bode plot

I would like to get the same plot in MATLAB as I do in Wolfram Alpha, to obtain the filter coefficients with fvtool so I can write a filter in C.Therefore my question is how do manage to convert the poles and zeros of the transfer function into the right format so that MATLAB does the same plot like Wolfram Alpha? What am I doing wrong?

Your issue is that you are mixing concepts

freqz is for z -based discrete frequency transforms, while you are working with s -based continuous Laplace transforms. These are unequivocally not the same thing.

Just use the functions for continuous transforms.

z = [-1];                  %zeros
p = [1];                   %poles
k = 1;                     %gain
[num,den] = zp2tf(z,p,k);  %convert zero-pole into numerator denominator
my_filter=tf(num,den);
bode(my_filter);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM