Limitations of Embedded MATLAB functions: Filter design in EMF possible?
1 次查看(过去 30 天)
显示 更早的评论
Please note that I am using Matlab 2009b for my project. Nonetheless, I am convinced that this does affect later versions as well.
I have the following simple setup that does not work:
- My MATLAB script to execute the simulation:
clc
sim('main');
- The Simulink Model with the EMF:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/149278/image.png)
The content of the embedded MATLAB function:
function output = PSF_SW(freq_peak)
order = 30;
freq = [0 freq_peak-0.2 freq_peak-0.1 freq_peak+0.1 freq_peak+0.2 1];
mag = [0 0 1 1 0 0];
output = firpm(order,freq,mag);
Executing the MATLAB script, I receive the error message:
??? Error using ==> runmain at 4
Error due to multiple causes.
Caused by:
Error using ==> runmain at 4
Error reported by S-function 'sf_sfun' in
'main/Embedded MATLAB Function/ SFunction ':
Errors occurred during parsing of Embedded MATLAB
function 'Embedded MATLAB
Function'(#18)
Error using ==> runmain at 4
Error in port widths or dimensions. Output port 1 of
'main/Embedded MATLAB Function/freq_peak' is a one
dimensional vector with 1 elements
As you can see, I want to design a digital bandpass filter in real-time. However, this seems to be impossible since the error occurs each time the inputs of firpm depend on the inputs of the EMF. I do not receive an error, if I define freq_peak inside the EMF. Is there another way to do this? Is this problem related to the fact that MATLAB's code generation procedure does not allow dynamic memory allocation?
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Introduction to Installation and Licensing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!