failed to generate MEX function, generation of trial code failed
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I am trying convert my matlab code in order to speed up thye computational time.
let me describe my function is, first I read a filename with some extention name and then passing into low pass filter and get the dominant freq, also calculate instatneous freq and calculate permutation entropy. I need to speed up my calculation because my input file is 24 hour with 100 sampling rate and for each month it contain 2232 files. I will do more than 3 years.
I use matlab coder to transfor to max file, but when it arrived at check for runtime issues, it said that generation of trial code is failed. I don't know why because it doesn't show anything in "Target Build Log" part.
Almost forget to mention that in command window it appear message eventough Matlab Coder window appear
Caught "std::exception" Exception message is:
Unable to load bundle binary /usr/local/MATLAB/R2020b/bin/glnxa64/builtins/shared_dastudio_builtins/mwdastudio_builtinimpl.so. Error: /lib64/libharfbuzz.so.0: undefined symbol: FT_Get_Transform: Success
here I include my function
function [time_exec]= calcPE_test(mfilename)
%#codegen
list=dir([mfilename '/*.DAT']);
N = length(list);
PEval=cell(1,N);
PEvalIF=cell(1,N);
domfreq=cell(1,N);
tStart=tic;
for m=1:length(list)
thisfile = list(m).name ;
if(coder.target('MATLAB'))
sig = importdata(thisfile);
end
%lowpass filter (<7Hz)
fc=7; %frequency corner
fs=100; %frequency sampling
Wn = fc/(fs/2);
n=5; %filter order, check filter response using
[b,a] = butter(n, Wn, 'low'); %lowpass filter
sigfil= filtfilt(b,a,sig); %sigfill is filtered signal
% calculate fft
n=length(sigfil);
srate=100; %sampling rate
nyq=srate/2;
dataX=fft(sigfil-mean(sigfil))/n; %dataX is fft result from filtered signal
hz=linspace(0,nyq,floor(n/2)+1);
pow=2*abs(dataX(1:length(hz)));
%get the maximum freq/dominant freq
[~,idx] = max(pow) ;
maxFreq = hz(idx);
domfreq{m}=maxFreq;
%Hilbert transform to get real and imag part
hilsig = hilbert(sigfil);
inphase=atand(imag(hilsig)./real(hilsig)); %inphase is instantaneous phase
%calculate permutation entropy from filtered signal and IF
PEfilt = permuentropy_test(sigfil,5,3);
PEval{m}=PEfilt;
PEIF = permuentropy_test(inphase,5,3);
PEvalIF{m}=PEIF;
end
%writting result in array and save in ascii
if(coder.target('MATLAB'))
dlmwrite ('PE_filt.dat', PEval)
dlmwrite ('PE_IF.dat', PEvalIF)
dlmwrite ('dom_freq.dat', domfreq)
end
tEnd = toc(tStart);
time_exec=datevec(tEnd./(60*60*24)); %change time in tictoc to
%PLOTTING PART
fig=figure();
%plot PE vs PE_IF
subplot 211
PE=load('PE_filt.dat'); IF=load('PE_IF.dat');
plot(PE,'o-')%,'markerfacecolor','b')
hold on
plot(IF,'o-')%,'markerfacecolor','r')
title('Comparation PE of filtered signal and PE of Instantaneous Phase')%,'(both after lowpassfiltered applied)')
%legend('PE from ori signal','PE from filtered IF', 'location','southeast')
ylabel('PE value')
%plot dominant freq
subplot 212
freq=load('dom_freq.dat');
plot(freq,'o-','markerfacecolor','b')
title('Dominant Frequency')
xlabel('time(*20minutes)')
ylabel('frequency (Hz)')
if(coder.target('MATLAB'))
saveas(fig,'PE_IF_DominantFreq_test.png');
end
end
1 comentario
SACHIN KHANDELWAL
el 25 de Jun. de 2024
I couldn't exactly replicate the issue, but I found this MATLAB Answers post that might help you:
Thanks,
Sachin
Respuestas (1)
Naman Saraf
el 11 de Jul. de 2024
Can you provide the details on the input to the code generation process? Also, a suggestion, you can only generate MEX for the processing part of the system, i.e. filtering etc. and keep the data import and export part in MATLAB.
0 comentarios
Ver también
Categorías
Más información sobre Adaptive Filters en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!