I have created a function lpf which uses fdesign.lowpass,design and filter functions.Then builded a C++ Dll to call this lpf function from VC++.Function is returning zero everytime in an array of size 100.I have pasted the code for description
2 views (last 30 days)
Show older comments
MAT LAB Version 7.0.0.19920 (R14)
Data passed(100 values) to function lpf and lpf1.
x=[10,5,100,50,20,10,5,100,50,20,10,5,100,50,20,10,5,100,50,20,10,5,100,50,20,10,5,100,50,20,10,5,100,50,20,10,5,100,50,20,10,5,100,50,20,10,5,100,50,20,10,5,100,50,20,10,5,100,50,20,10,5,100,50,20,10,5,100,50,20,10,5,100,50,20,10,5,100,50,20,10,5,100,50,20,10,5,100,50,20,10,5,100,50,20,10,5,100,50,20]
Other Parameters passed are
Order n = 2
CutOff frq fc = 3
Sampling Rate s = 20
I am Using lpf function as following
function z=lpf(x,n,fc,s)
hl = fdesign.lowpass('N,Fc', n, fc, s);
Hdl = design(hl, 'butter');
z=filter(Hdl,x);
It is executing fine from matlab command window.Now i builded dll to use it in VC++ and then called from Vc++,function is returning always zero in an array.
To crosscheck I used lpf1 function as following
function y=lpf1(x)
b=[1 2 1];
a=[ 1 -0 0.17157287525381];
y=filter(b,a,x);
This function executed fine in matlab command window.Then i builded dll to use it in VC++,I got the desired result with filtered values in an array.
So my question is why lpf is not working but lpf1 is working when calling both functions from VC++ after building dll in matlab.
What is the reason that lpf is returning always zero in an array in VC++ but filtered or desired output in matlab command window.
1 Comment
Oleg Komarov
on 11 Sep 2012
Please format the code http://www.mathworks.com/matlabcentral/answers/13205-tutorial-how-to-format-your-question-with-markup.
Also, change the title of your question to something short and meaningful.
Those changes will make it likely that somebody answers.
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!