- refactored
This commit is contained in:
Executable
+66
@@ -0,0 +1,66 @@
|
||||
% pltimp(x,Fa,Nw,NP)
|
||||
function y = pltimp(x,Fa,Nw,NP)
|
||||
|
||||
xn = x(1:NP)/max(x(1:NP));
|
||||
Px = sm2(xn(1:NP).^2,Nw,0);
|
||||
Pxn = Px/max(Px(1:NP));
|
||||
PxndB = 10*log(Pxn(1:NP));
|
||||
|
||||
matchval = -120;
|
||||
for n = 1:NP,
|
||||
if ((PxndB(n) <= -60) & (PxndB(n) > matchval))
|
||||
matchn = n;
|
||||
matchval = PxndB(n);
|
||||
end;
|
||||
if (PxndB(n) > -60)
|
||||
matchval = -120;
|
||||
end;
|
||||
end;
|
||||
|
||||
matchtime = matchn*1000/Fa
|
||||
matchval
|
||||
|
||||
figure;
|
||||
plot(1000*(1:NP)/Fa,x(1:NP));
|
||||
grid;
|
||||
PlotTitle = sprintf('h(t) Fa=%d Hz',Fa);
|
||||
title(PlotTitle);
|
||||
xlabel('t [ms]');
|
||||
ylabel('h');
|
||||
|
||||
figure;
|
||||
plot(1000*(1:NP)/Fa,Px(1:NP));
|
||||
grid;
|
||||
PlotTitle = sprintf('Leistung Ph(t), Windowsize=%d Samples, Time=%g ms',Nw,1000*Nw/Fa);
|
||||
title(PlotTitle);
|
||||
xlabel('t [ms]');
|
||||
ylabel('eh');
|
||||
|
||||
figure;
|
||||
plot(1000*(1:NP)/Fa,PxndB(1:NP));
|
||||
set(gca,'YTick',-20*(0:6));
|
||||
xt = get(gca,'XTick');
|
||||
rval = 100;
|
||||
di = 1;
|
||||
for i = 1:length(xt)-1,
|
||||
lv = round(matchtime) - xt(i);
|
||||
if (lv <= 0)
|
||||
di = i;
|
||||
if (i > 1)
|
||||
uv = round(matchtime) - xt(i-1);
|
||||
if (abs(uv) < abs(lv))
|
||||
di = i - 1;
|
||||
end;
|
||||
break;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
di
|
||||
xt(di) = matchn*1000/Fa;
|
||||
set(gca,'XTick',xt);
|
||||
grid;
|
||||
PlotTitle = sprintf('Leistung Ph(t) 60dB-decay time=%g ms',matchtime);
|
||||
title(PlotTitle);
|
||||
xlabel('t [ms]');
|
||||
ylabel('Ph [dB]');
|
||||
|
||||
Reference in New Issue
Block a user