Hello, I'm having problems with the "freqs" or "freqz" function

I'm using a code that I found in MATLAB, to check if my code for another program is wrong. But this code that I found does not work either.
a = [1 0.4 1];
b = [0.2 0.3 1];
w = logspace(-1,1);
h = freqs(b,a,w);
mag = abs(h);
phase = angle(h);
phasedeg = phase*180/pi;
subplot(2,1,1)
loglog(w,mag)
grid on
xlabel('Frequency (rad/s)')
ylabel('Magnitude')
subplot(2,1,2)
semilogx(w,phasedeg)
grid on
xlabel('Frequency (rad/s)')
ylabel('Phase (degrees)')
This is the error I'm getting
Undefined function 'freqs' for input arguments of type 'double'.
Error in untitled4 (line 5)
h = freqs(b,a,w);
Do I need to activate the "freqs" function in MATLAB? I'm new to it, and don't have lots of experience generating code or using it. Thank you for any help.

Answers (1)

You need to license and install the Signal Processing Toolbox.
If you purchased the MATLAB Student Suite then if I recall correctly that particular toolbox is included in the license; if you purchased MATLAB Student (not Suite) then it would not have been included by default.

2 Comments

I activated the signal processing toolbox, but I still get the same error??
What shows up for you if you use the following commands?
ver('signal')
----------------------------------------------------------------------------------------------------- MATLAB Version: 9.13.0.2182233 (R2022b) Update 4 MATLAB License Number: 0 Operating System: Linux 5.4.224-0504224-generic #202211101403 SMP Thu Nov 10 21:10:29 UTC 2022 x86_64 Java Version: Java 1.8.0_292-b10 with AdoptOpenJDK OpenJDK 64-Bit Server VM mixed mode ----------------------------------------------------------------------------------------------------- Signal Processing Toolbox Version 9.1 (R2022b)
license('test', 'Signal_Toolbox')
ans = 1
Note: these exact names are important (though they are not case sensitive.) For example, testing 'signal' or 'signal_processing_toolbox' or 'signal toolbox' will fail.

Sign in to comment.

Asked:

on 7 Mar 2023

Commented:

on 9 Mar 2023

Community Treasure Hunt

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

Start Hunting!