필터 지우기
필터 지우기

why i'm getting this error?

조회 수: 1 (최근 30일)
ocsse
ocsse 2018년 3월 25일
편집: ocsse 2018년 3월 25일
why i'm getting this error: Error using * Inner matrix dimensions must agree.
thanks
  댓글 수: 2
David Fletcher
David Fletcher 2018년 3월 25일
편집: David Fletcher 2018년 3월 25일
Sounds like you're trying to do inner matrix multiplication rather than element by element multiplication
possibly here: (a line number where the error occurred might be handy)
*an*cos*(2*pi*f0*n.'*t) + *bn*sin*(2*pi*f0*n.'*t
instead of
an.*cos(2*pi*f0*n.'*t) + bn.*sin(2*pi*f0*n.'*t
ocsse
ocsse 2018년 3월 25일
still getting an error

댓글을 달려면 로그인하십시오.

채택된 답변

Star Strider
Star Strider 2018년 3월 25일
Your ‘an’ and ‘bn’ are (1x4) vectors, and ‘t’ is (1x500).
One way to avoid it is to transpose ‘an’ and ‘bn’ to column vectors:
s = s + a0 + an'*cos(2*pi*f0*n.'*t) + bn'*sin(2*pi*f0*n.'*t);
I do not know what you want for a final result. If you want a single row vector for each ‘n’, sum them:
s = s + a0 + sum(an'*cos(2*pi*f0*n.'*t) + bn'*sin(2*pi*f0*n.'*t));

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Descriptive Statistics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by