Need help troubleshooting MatLab error

I need help troubleshooting this error message,
Matrix dimensions must agree.
Error in myExperimentThreeLab6 (line 38) Error1 = y ./ x2;
function myExperimentThreeLab6(~)
load handel.mat y;
%sound(y,8192);
% Experiment Three
subplot(4,1,1);
stem(y(100:18000));
title('Original Signal');
% A)
x1 = fft(y,10000);
x2 = ifft(x1,10000);
subplot(4,1,2);
stem(x2);
title('Signal at 10,000');
% B)
x3 = fft(y,16000);
x4 = ifft(x3,16000);
subplot(4,1,3);
stem(x4);
title('Signal at 16,000');
% C)
x5 = fft(y,17901);
x6 = ifft(x5,17901);
subplot(4,1,4);
stem(x6);
title('Signal aat 17,901');
% Experiment Four
Error1 = y ./ x2;
Error2 = y ./ x4;
Error3 = y ./ x6;
fprintf('Errror at 10,000 = %f \n ', Error1);
fprintf('Errror at 16000 = %f \n ', Error2);
fprintf('Errror at 10,000 = %f \n ', Error3);
end

回答 (1 件)

Image Analyst
Image Analyst 2018 年 5 月 29 日

0 投票

y is 73113 elements long while x2 is 10000 elements long. How/why do you expect that to work???

3 件のコメント

Austin Gaylor
Austin Gaylor 2018 年 5 月 30 日
how would I index the array so I have the same dimensions?
Image Analyst
Image Analyst 2018 年 5 月 30 日
You could use interp1(), but you really need to understand what you want to do, because that's not really the right thing to do. It's just a bandaid patch to the problem that doesn't fix the real problem
Austin Gaylor
Austin Gaylor 2018 年 5 月 30 日
Okay, thank you. What I am trying to do is use fft() and ifft() to find the Fourier Transform oh handel.mat, then reconstruct the signal at different approximation terms. That is were the 10000, 16000, 17901 came from.

サインインしてコメントする。

質問済み:

2018 年 5 月 29 日

コメント済み:

2018 年 5 月 30 日

Community Treasure Hunt

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

Start Hunting!

Translated by