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

1 Ansicht (letzte 30 Tage)
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 Kommentare
Ced
Ced am 26 Mär. 2016
Bearbeitet: Ced am 27 Mär. 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.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Jason Nicholson
Jason Nicholson am 27 Mär. 2016
Bearbeitet: Jason Nicholson am 27 Mär. 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.

Weitere Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by