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

1 次查看(过去 30 天)
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 个评论
Ced
Ced 2016-3-26
编辑:Ced 2016-3-27
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.

请先登录,再进行评论。

采纳的回答

Jason Nicholson
Jason Nicholson 2016-3-27
编辑:Jason Nicholson 2016-3-27
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.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Mathematics and Optimization 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by