Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Error using .* Matrix dimensions must agree. HELP

조회 수: 3 (최근 30일)
Kayn
Kayn 2013년 11월 7일
마감: MATLAB Answer Bot 2021년 8월 20일
Hi all, when I run this script
kR = 0:1:12;
phi = 0:pi/4:pi/2;
zeta = pi/2;
pre = cos(kR .* sin(phi) .* cos(zeta));
term1 = (1 - 1i * kR) * (1 - 3 * cos (phi) .* cos (phi));
term2 = kR .* kR .* sin (phi) .* sin (phi);
term = (term1 - term2) .* exp (1i * kR);
result = term .* pre;
y = real(result) ./ kR^3 ;
contourf(kR,phi,y)
-----------------------------
I keep getting the error - Error using .* Matrix dimensions must agree.
Error in Forceed (line 9) pre = cos(kR .* sin(phi) .* cos(zeta));
Is this a syntax problem? I can't seem to get it to work. Any help appreciated.

답변 (1개)

James Tursa
James Tursa 2013년 11월 7일
Hint: Look at size(kR) and size(phi). You also need to look at the other lines for your use of * vs .* operation, since it looks like you will have similar problems there as well.

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by