How can I correct this error?

1 次查看(过去 30 天)
Kangmin Lee
Kangmin Lee 2021-4-26
>> 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.

回答(1 个)

Divija Aleti
Divija Aleti 2021-4-29
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.
For more infomation, refer to this link: Array vs.Matrix Operations
Hope this helps!
Regards,
Divija

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!