i am solving over-determined system but when i run my code its give me result inner dimension mismatch how to solve it

1 visualización (últimos 30 días)
l=0:28
N=28
for k=1:7
k1=k+(n*7);
k2=k+(n*7);
M=[1 1 ; e^(j*2*3.14)*(k1-1)*(l/N) e^(j*2*3.14)*(k2-1)*(l/N) ;e^(j*2*3.14)*(k1-1)*(l/N) e^(j*2*3.14)*(k2-1)*(l/N)];
end
  2 comentarios
Ced
Ced el 26 de Mzo. de 2016
Editada: Ced el 27 de Mzo. de 2016
You are aware that matlab includes constants such as e and pi?
First row of M: 2 elements
Second row of M: 29 elements (from l)
--> PROBLEM!
EDIT After reading Walter's comment, I realized my answer was not clear. As he correctly points out, you need to use exp(1) to compute e^1. I just meant that you don't have to plug in the "e" number manually.

Iniciar sesión para comentar.

Respuesta aceptada

Jason Nicholson
Jason Nicholson el 27 de Mzo. de 2016
Editada: Jason Nicholson el 27 de Mzo. de 2016
Your code is a bit cryptic because it is clear you don't know the right MATLAB syntax. So the way I will try to help is guess at what you were trying to do and rewrite your code.
l=(0:28)'; % size is now 29 x 1
N=28;
for k=1:7
k1=k+(N*7);
k2=k+(N*7);
M=[1, 1 ;
exp(1j*2*pi)*(k1-1)*(l/N), exp(1j*2*pi)*(k2-1)*(l/N) ;
exp(1j*2*pi)*(k1-1)*(l/N), exp(1j*2*pi)*(k2-1)*(l/N)];
end
Note that the code above still doesn't make sense for an over-determined system of equations. Therefore, I am going to speak about over-determined linear algebraic equations systems as follows.
Given: You have the over determined system A*x = b where A is an m x n matrix and m > n. You want to minimize the norm(Ax - b) in the least squares sense (i.e. best coefficient vector x). To do this in MATLAB, use the following:
x = A\b
When A is rectangular rather than square, MATLAB computes the least squares solution.
If this helped you, please mark my answer as the accepted answer. Otherwise, post some more information so that we can try to better answer your question.

Más respuestas (0)

Categorías

Más información sobre Mathematics and Optimization 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