Clear Filters
Clear Filters

Why my calculation result is not matrix result?

2 views (last 30 days)
ZHU z
ZHU z on 10 Apr 2022
Commented: ZHU z on 13 Apr 2022
The result of my matla calculation is a numerical value instead of a matrix result, so I can't draw the relevant graph(figure3):
——The output of AweightedSPL and SPL is a numerical rather than a matrix result,So I can't plot the "frequency-AweightedSPL "spectrum. Input audio has been uploaded
can someone help me see where the code can go wrong?How should I change it?
thanks~
[x,fs] = audioread('123.wav');
L = length(x);
y=fft(x);
f =fs/2.*linspace(0,1,L/2+1);
y = y(1:L/2+1);
plot(f,abs(y),'b');
A= filterA(f);
yweighted = A'.*y;
figure(1);
plot(f,abs(yweighted),'r');
xweighted = ifft(yweighted);
xweighted = real(xweighted);
tempdata = xweighted;
tempL = length(tempdata);
temp1 = fft(tempdata)/tempL*2;
figure(2);
plot(f,abs(temp1),'g');
linelevel =1.8;
preampout = abs(xweighted.*1.8);
preampin = preampout;
pressure = 1000.*preampin./22.78;
pref = 0.00002;
pressure = sqrt(mean(pressure.^2));
AweightedSPL =20.*log10(pressure/pref);
figure(3);
plot(f,AweightedSPL,'b');grid
  8 Comments
ZHU z
ZHU z on 12 Apr 2022
thank you @Matt J
Sorry for the long wait, the input file has been uploaded~

Sign in to comment.

Answers (0)

Categories

Find more on Audio Toolbox in Help Center and File Exchange

Products


Release

R2017a

Community Treasure Hunt

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

Start Hunting!