Proper usage of 'daqdocfft' in embedded matlab

10 views (last 30 days)
I am trying to apply MAP weighting onto data acquired from the 'analog input' block in embedded matlab setup.
The analog input block with a sampling rate = 16000, block size = 5, signal type = sample based and Asynchronous acquisition is used. This is then fed to the embedded matlab block where I have the following code.
function uMap = mapWeighting(u)
%#eml
% Some Declarations and initializations to avoid 'mxArray' related errors
i = 0; TL = 0; uFL = 0;
Fs = 16000;
T = zeros(40000,1);
uF = zeros(40000,1);
uMAG = zeros(40000,1);
uMAG_MAP = zeros(40000,1);
% aData = zeros(5,1); OR aData = zeros(80000,1); OR aData = zeros(size(u));
% aData = u;
eml.extrinsic('daqdocfft','length');
[uF,uMAG] = daqdocfft(u,Fs,5*Fs);
% [uF,uMAG] = daqdocfft(u,Fs,5*Fs);
% Use for loops to get rid of the errors due to the vector operations here
uFL = length(uF);
for i = 1 : uFL
T(i) = ( 3.64 * ((uF(i)/1000)^-0.8) ) ...
- ( 6.5 * exp(-0.6 * ((uF(i)/(1000-3.3))^3)) ) ...
+ ( 10^-3 * ((uF(i)/1000)^4) );
end
% Finally apply the weighting T onto the magnitude of the recorded samples
TL = length(T);
for j = 1 : TL
uMAG_MAP(j) = uMAG(j) * T(j);
end
% Assignment to the return variable 'uMap'
uMap = uMAG_MAP;
When I run this, I get the following error,
---------------------------------------------------------------
Embedded MATLAB Interface Error: Call to MATLAB function aborted: Index exceeds matrix dimensions. Block Embedded MATLAB Function (#28) While executing: none.
----------------------------------------------------------------
I fail to understand, what the problem here is?
I tried to use an intermediate variable and assign the values of input 'u' to it, so that I can explicitly give the details of the dimensions.
Using,
1) aData = zeros(5,1) or zeros(size(u)) --> gives the same error as above.
2) aData = zeros(80000,1) --> gives a size mismatch error shown below
-------------------------------------------------------------
Size mismatch (size [80000 x 1] ~= size [5 x 1]). The size to the left is the size of the left-hand side of the assignment.
-------------------------------------------------------------
The code works fine, if I remove the analog input block and make and extrinsic call to 'wavread' a file and perform the operations.
--Things to know--
MATLAB 32-bit version running on 64-bit Windows 7 (Please let me know if there is anything else needed to know)
What am I missing here or doing wrong?
Please guide. Many thanks in advance.

Answers (0)

Categories

Find more on Simultaneous and Synchronized Operations in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!