Matrix dimensions must agree error
1 回表示 (過去 30 日間)
古いコメントを表示
Jordan Reece Duggan
2021 年 3 月 9 日
コメント済み: Jordan Reece Duggan
2021 年 3 月 12 日
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!