I have a MATLAB code shown in below. I am trying to convert this code to C code using MATLAB Coder but I encountered an error.
Expected either a logical, char, int, fi, single, or double. Found an mxArray. MxArrays are returned from calls to the MATLAB interpreter and are not supported inside expressions. They may only be used on the right-hand side of assignments and as arguments to extrinsic functions.
% Applies A-weighted filtering to sound and draws it's plot
% in a figure as output.
function A_filtering
coder.extrinsic('tic')
coder.extrinsic('toc')
coder.extrinsic('display')
sampleRate = 44100;
reader = dsp.AudioFileReader('Jet_Flypast.wav');
fs = 44100;
weightFilter = weightingFilter('A-weighting',fs);
% fileWriter = dsp.AudioFileWriter('SampleRate',fs);
% visualize(weightFilter,'class 1')
scope = dsp.SpectrumAnalyzer('SampleRate',fs,...
'PlotAsTwoSidedSpectrum',false,...
'FrequencyScale','Log',...
'FrequencyResolutionMethod','WindowLength',...
'WindowLength',sampleRate,...
'Title','A-weighted filtering',...
'ShowLegend',true,...
'ChannelNames',{'Original Signal','Filtered Signal'});
tic
while toc < 60
x = reader();
y = weightFilter(x);
scope([x(:,1),y(:,1)])
display(x(:,1))
end
release(scope);
release(weightFilter);
release(reader);
end
This question might be a duplicate but I searched internet and couldn't find any related posts. Is there any way to solve this error?