Question
I am trying to get a C code for the peaking IIR filter, but I am getting the following error in MATLAB Code Report Viewer.I am attaching the MATLAB code below .Please help me to debug this error .Any help would be appreciated function Hd = Filter1_150_matlab %FILTER1_150_MATLAB Returns a discrete-time filter object. % MATLAB Code % Generated by MATLAB(R) 9.4 and DSP System Toolbox 9.6. % Generated on: 26-Mar-2019 16:44:54 % IIR Peaking filter designed using the IIRPEAK function. % All frequency values are in Hz. Fs = 1000; % Sampling Frequency Fpeak = 150; % Peak Frequency Q = 100; % Q-factor Apass = 1; % Bandwidth Attenuation BW = Fpeak/Q; % Calculate the coefficients using the IIRNOTCHPEAK function. [b, a] = iirpeak(Fpeak/(Fs/2), BW/(Fs/2), Apass); Hd = dsp.IIRFilter( ... 'Structure', 'Direct form II', ... 'Numerator', b, ... 'Denominator', a); num = [0.0092 0 -0.0092] den = [1 -1.1648 0.9816] %Hz1 = filt(num,den) %disp(Hz1) % [EOF] I am getting following error message Handle Classes in top-level outputs are not supported in MATLAB Coder. Output parameter 'Hd' contains a handle class.
Expert Answer
Kshitij Singh
PhD Expert
Answered Aug 24, 2026
Based on the error message, Hd (a dsp.IIRFilter) contains a member that is a handle class, which let multiple names refer to the same object.
While handle classes are supported for code generation, as of R2019a, they are not yet supported as inputs or outputs (or data members of inputs or outputs) to entry-point functions (the function name you tell MATLAB Coder to generate code for).
We've made an internal note of your request so we can look at lifting that limitation in the future.
For now, a workaround is to pass non-handle data as output.
Instead of the filter as output, the function could take in input data and output the result of the filter on that data.
100% Run Guarantee
3-Hour Fast-Track Delivery
Need a Custom Version or Complete Simulation for This Problem?
Our 500+ PhD engineers build, debug, and optimize working MATLAB scripts and Simulink (.slx) models tailored to your exact assignment rubrics with zero plagiarism.
Tested on MATLAB R2024b / R2026a
Turnitin 0% Plagiarism Report
Free 7-Day Revisions Guarantee
Have a different question? Ask here
Related simulink Questions & Solutions
Browse All →
Explore similar technical troubleshooting questions and verified MATLAB solutions:
Ready-to-Run MATLAB & Simulink Projects
Browse All Projects →