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.
Walter Roberson
Walter Roberson 2016 年 3 月 27 日
MATLAB does not have a constant for e: you would code exp(1) to get e.

サインインしてコメントする。

採用された回答

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.
  1 件のコメント
irfan
irfan 2016 年 3 月 28 日
thanks for your help sir your gaudiness help me and it perfectly working i am very thankful of you

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by