Matrix dimensions must agree error
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi all,
Ive got some code from my tutor thats meant to be filtering a medical signal (ecc) by multiplication in the frequency domain, all goes well till Y5=X5.*HBR; , there it says matrix dimensions must agree, been rattling my head about this for a while but cant figure out where the conflict is, tutor wont help either.
fs=500;
n=2;
Wn=40/250;
[B, A] = butter(n,Wn);
printsys(B, A, 'z' );
x1=eye(1,1000); % create an impulse
plot(x1)
pause
hb=filter(B, A, x1); % calculate the impulse response of the Butterworth filter
plot(hb)
pause
freqz(B, A, 1024, fs)% create frequency response plots
set(gca, 'XScale', 'log')
pause
medical = 'medical signal.dat'; %this needs to be the location of the waveform
xmed = load(medical);
plot(xmed) % display the noisy waveform
pause
X5=fft(xmed)/length(xmed); % calculate the FFT of the signal
f=fs/length(X5)*(0:length(X5)-1);
plot(f, abs(X5)); % display the signal spectrum
pause
HBC = fft(hb)/length(hb); % calculate the FFT of the filter impulse response
HBR = HBC.' ; % convert the result to a row vector
f=fs/length(HBR)*(0:length(HBR)-1);
plot(f, abs(HBR)); % display the magnitude of the filter frequency response
pause
Y5 = X5.'HBR; % multiply the signal fft by the filter frequency response
plot(f,Y5) % display the frequency response of the result
pause
y5=ifft(Y5)*(length(Y5))^2; % convert the result back into the time domain
plot(y5) % display the filtered waveform
pause
Any suggestions on whats causing the matrixes to conflict?
Cheers
댓글 수: 1
KSSV
2021년 3월 10일
This lineL
Y5 = X5.'HBR; % multiply the signal fft by the filter frequency response
is not correct. You need to change it.
Learn about debugging and check the dimensions where you are getting error.
채택된 답변
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!