# How can I correct this error?

1 view (last 30 days)
Kangmin Lee on 26 Apr 2021
Answered: Divija Aleti on 29 Apr 2021
>> x=0:0.1:30;
>> y=-10:0.1:10;
>> [X,Y] = meshgrid(x,y);
>> syms u
>> A = (8*9.81/(27))*(cosh(0.01*u))^2*cos((9.81/9*X*cosh(0.01*u))*cos((9.81/9)*Y*cosh(0.01*u)*sinh(0.01*u))*exp(-(9.81/9)*(cosh(0.01*u))^2*2));
다음 사용 중 오류가 발생함: * (334번 라인)
Dimensions do not match.

Divija Aleti on 29 Apr 2021
Hi Kangmin,
Have a look at the following snapshot of your code: The matrix above the blue line and the matrix above the red line are of the same dimensions,i.e.,201 x 301. In order to multiply two matrices using (*), the number of columns in the first matrix should be equal to the number of rows in the second matrix. But here, that is not the case. This is why you are getting the error.
Depending on the problem you are solving, you can either use the dot operator with multiplication(.*) which multiplies the matrices element-wise, or take the transpose of one of the matrices and perform normal multiplication. The ‘regular’ matrix transpose (') creates the complex-conjugate transpose of a complex vector or matrix. Using the (.') creates the transpose without doing the complex-conjugate operation.
Hope this helps!
Regards,
Divija