Wednesday 15 June 2011

debugging - Error in MATLAB code -


Then I wrote the following code and I get an error which says:

  ==> Matrix dimensions should be repeatedly agreed. ==> Error 28 on the edges without title 2 = ifft (fft (song). * Fft (myFilter));   

This is the code I used:

  [song, fs] = wavread ('c scale fast.wav'); P = 20000/44100 * FS; Filter length% N = length (song); Song Length = 0: 1 / FS: (Length (song) -1) / FS; % And sample frequency song = song / max (stomach (song)); % Gaussian filter x = linspace (-1, 1, n); Include vector vector of between -1 and 1 sigma = 0.335; Gausi formula myphilter = -x *% Standard deviation used in APP (- ^ x ^ 2) / (2 * sigma. ^ 2);% prefixed myFilter = myFilter / sum (myFilter)); % Normalize% fft convolution song = song (:); MyFilter = myFilter (:); Song (length (song) + length (myFilter) -1) = 0; MyFilter (Length (song) + Length (MyFilter-1) = 0; Edges = ifft (fft (song). * Fft (myFilter)); Tedge = Edge (P / 2: N + P / 2-1); P / Shift by% 2 then peaks line up w / edges tedges = tedges / maximum (abs (tedges)); Can anyone tell me what's wrong here? ?   

Well, your error tells you what line your error is on, then on that line It also tells you which tasks are of error The time is "You" do not know what it is, so you are seeing it in the doctor file, it exits. Operator. Your error tells you that "Matrix dimensions do not agree" - what's this Does matrix, dimension, do not agree - you have two variables different sizes.

  Song (length (song) + length (myFilter) -1) = 0; MyFilter (Length (song) ) + Length (MyFilter-1) = 0; Edges = ifft (fft (song). * Fft (myFilter));   

These rows are Your error is that you are extending the length of the song and then defining myFilter over the length of the song , then trying again Are there. * It's (converted) code> song . Unless you tell many points to use fft / ifft, you will get the output of the same size of input, so it is not going to work. I imagine that you want them to be both the same length. Then, something like this should be done:

  song (length (song) + length (myFilter) -1) = 0; MyFilter (Length (song)) = 0;   

I do not think you mean to change the length of the song. I think you need to:

  myFilter (length (song)) = 0; Instead of   

  song (length (song) + length (myFilter) -1) = 0; MyFilter (Length (song) + Length (MyFilter -1) = 0;    

No comments:

Post a Comment