# matrix multiplication dimension issues

1 visualización (últimos 30 días)
Douglas Brenner el 6 de Dic. de 2018
Respondida: Douglas Brenner el 7 de Dic. de 2018
I have an article which I'm trying to follow. It calculates two matricies that I called synch and async.
I read two files into two matricies; find the starting locations I want; and select n points. The I transpose the matricies (spect1 and spect2) each ending up being 200 x 2.
I then do matrix multiplication (synch = spect1(2:n, : )*spect2(2:n, :)'/(n-2);) on line 43 and get what I am pretty sure is the right output. However, this is not the formula in the article. The formula in the article is synch = spect1(:, 2:n)*spect2(:,2:n)'/(n-2); This gives me an Index exceeds matrix dimensions error. Not transposing the matricies after reading them in doesn't help. I get the wrong answer.
The calculation for async is on line 63. The article says async = spect1(:, 2:n) * N *spect2(:, 2:n)' /(n-2) but both ordering of the dimensions gives the Index exceeds matrix dimensions error.
Any help would be appreicated.
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

### Respuestas (3)

James Tursa el 6 de Dic. de 2018
Editada: James Tursa el 6 de Dic. de 2018
If the formula in the article has the calculation as async = spect1(:, 2:n) * N * spect2(:, 2:n)'/(n-2) , and N is an (n-1)x(n-1) size matrix, it seems pretty clear that your spect1 and spect2 should be 2x200 instead of 200x2. So don't transpose the data in the beginning. I.e., let spect1 and spect2 be 2x200 and then use the formulas as-is from the article. Then you should be able to do this:
sync = spect1(:, 2:n) * spect2(:, 2:n)'/(n-2);
async = spect1(:, 2:n) * N * spect2(:, 2:n)'/(n-2);
Is the data real or complex? Are you sure the data in spect1 and spect2 is in the correct order? (maybe your spect1 data should be in spect2 and vice-versa)
##### 2 comentariosMostrar NingunoOcultar Ninguno
Douglas Brenner el 6 de Dic. de 2018
So I did that and it did indeed run but the answer is a 2x2 matrix when I expect one that's 199X199.
James Tursa el 6 de Dic. de 2018
Editada: James Tursa el 6 de Dic. de 2018
In your code, the N matrix is (n-1)x(n-1). How can you possibly use the async formula to end up with an (n-1)x(n-1) matrix? Why are you expecting this size as a result? spect1 and spect2 would have to be 199x200 size in order for this to agree with your expectations.

Iniciar sesión para comentar.

Douglas Brenner el 6 de Dic. de 2018
The basic science is to take two spectra and perform a 2d cross correlation resulting in a real and a complex matrix. They should be nxn or maybe in the case of the imaginary matrix (sync) 199 x 199. So I know what I should get from what I have just haven't been able together there.
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

Douglas Brenner el 7 de Dic. de 2018
n is not the number of points in a spectrum but the number of spectra.
Thanks for trying
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

### Categorías

Más información sobre Frequently-used Algorithms en Help Center y File Exchange.

### Community Treasure Hunt

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

Start Hunting!

Translated by