How to access the variables in the for loop?
이전 댓글 표시
I need to be able to plot the error from this LPC analysis filter but it doesn't let me access it because it is in the loop. Is there anyway to be able to access it?
sound = audiorecorder(8000,16,1);
disp('Start speaking.');
recordblocking(sound,5);
disp('End of Recording.');
M = 10;
seg = 240;
if (size(x,2) == 1)
x = x';
end
npts = length(x);
nseg = floor(npts/seg);
for each = 1:nseg
xx = x((each - 1)*seg + [1:seg]);
[a,G] = lpc(xx, M);
e = filter(a,1,xx);
G = sqrt(G);
e = e/G;
parameter(each,:) = a;
gain(each) = G;
error((each - 1)*seg + [1:seg]) = e;
end
답변 (1개)
Walter Roberson
2022년 4월 20일
It is not clear to me why you cannot plot e inside the loop?
Create an animatedline() object before the loop.
Inside the loop, create a time vector which is the indices that you used in the line
xx = x((each - 1)*seg + [1:seg]);
but subtract 1, and then divide by the sampling frequency (8000 in this case.) Now you can
addPoints(t, e)
카테고리
도움말 센터 및 File Exchange에서 Signal Modeling에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!