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에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by