inner matrix must agree using *
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Nicholas Jacobs
am 23 Okt. 2015
Kommentiert: Star Strider
am 23 Okt. 2015
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))))
0 Kommentare
Akzeptierte Antwort
Star Strider
am 23 Okt. 2015
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 Kommentare
Star Strider
am 23 Okt. 2015
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.)
Weitere Antworten (1)
Eng. Fredius Magige
am 23 Okt. 2015
Hi, it might be
A= poly(1j.*wc.*exp((1j.*pi)./((2.*k)*(2.*k-1))))
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!