inner matrix must agree using *

조회 수: 1 (최근 30일)
Nicholas  Jacobs
Nicholas Jacobs 2015년 10월 23일
댓글: Star Strider 2015년 10월 23일
when attempting to execute this code I get the following error, can anyone tell me why and how to resolve it, thanks
A= poly(1j*wc*exp((1j*pi)/((2*k)*(2*k-1))))
Error using * Inner matrix dimensions must agree.
Error in Lab_03 (line 29) A= poly(1j.*wc.*exp((1j.*pi)./((2.*k)*(2.*k-1))))

채택된 답변

Star Strider
Star Strider 2015년 10월 23일
The poly function wants a vector of roots from which to create a polynomial. I have no idea what the sizes of your arguments (variables) are, so assuming they are all otherwise compatible, (have the same numbers of elements), vectorising the assignment seems the logical direction to go (assuming also that 1j indicates the imaginary operator):
A = poly(1j*wc.*exp((1j*pi)./((2*k).*(2*k-1))))
If that doesn’t work, please provide more information, particularly the sizes of ‘wc’ and ‘k’.
  댓글 수: 2
Nicholas  Jacobs
Nicholas Jacobs 2015년 10월 23일
right on brother, what you said did the trick. Thanks. Why do I need not use the dot operator at the other locations like I had before or like the guy above me wrote? Thanks again
Star Strider
Star Strider 2015년 10월 23일
My pleasure.
The dot operator specifies element-wise operations as opposed to conventional matrix operations. MATLAB defaults to matrix operations, so you have to specify element-wise operations. See the documentation for Array vs. Matrix Operations for a full description. (A useful function in dealing with arrays is bsxfun. I don’t know if you need it here, but it’s good to know about.)

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

추가 답변 (1개)

Eng. Fredius Magige
Eng. Fredius Magige 2015년 10월 23일
Hi, it might be
A= poly(1j.*wc.*exp((1j.*pi)./((2.*k)*(2.*k-1))))
  댓글 수: 1
Nicholas  Jacobs
Nicholas Jacobs 2015년 10월 23일
thanks for the input brother.

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

카테고리

Help CenterFile Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by