0

I create simulink block like below:

enter image description here

inside Interpreted MATLAB Function i use this code.

function y1 = fcn(signal)
%% variable declaration
Fm = 100;%length of Frames excursion
framelnc = 100;%length of Frames excursion
Fn = 256;%length of Frames sampling frequency 12.500kHz, frame length 020.5ms
fs = 8000;

x=signal;

%% Preprocessing: Noise Removal
IS= 0.25; % initial silence (noise only)
output=denoise(x,fs,IS);
y = output;

%% Extraction of LFCC Features
feat = lfcc(y,fs);

%% Extract VQ CODE
k=16; % number of centroids required

code1 = vqext(feat, k);
test = mean2(code1);

%% Emotions Recognition 
load ('train.mat')

Class = knnclassify(test , feature, type);

if (Class == 1)
   %% Display identification results
   msg=1;
end

if (Class == 2)
   %% Display identification results
    msg=2;
end

y1 = msg;

I defined these denoise,lfcc,vqext,knnclassify function in separate matlab files. but I got error like below.

enter image description here

How can I solve this problem?

1 Answer 1

1

At your picture we can see that formally your data has two dimensions [1024x1] ! So I think, that Interpreted MATLAB Function can't operate with this data type.

So I suggest to use Frame Conversion block.

P.S. Be the way, why are you use Interpreted function? is it really necessary?

Note This block is slower than the Fcn block because it calls the MATLAB parser during each integration step. Consider using built-in blocks (such as the Fcn block or the Math Function block) instead. Alternatively, you can write the function as a MATLAB S-function or MEX-file S-function, then access it using the S-Function block.

Sign up to request clarification or add additional context in comments.

7 Comments

Thankyou @ Mikhail_Sam
another problem i found is load the mat file. it loads into the work space only. i solve by dataset=load('train.mat'); feature=dataset.feature; type=dataset.type;
@ Mikhail_Sam i want to run this model in raspberry pi without using pc. i have multiple .m files for interpreted matlab function. can you help me?
really I have no experience of using raspberry pi, but we can try, of course - using .mat files in matlab and simulink is a common practice. But I recommend you to open new question about your exactly problem - me and a lot of people will help you!
@ Mikhail_Sam here i have lot of matlab functions(denoise, lfcc,vqext) in different files within Interpreted function. can i use MATLAB S-function in this situation ?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.