How can I correct this error?
3 ビュー (過去 30 日間)
Kangmin Lee 2021 年 4 月 26 日
回答済み: Divija Aleti 2021 年 4 月 29 日
>> [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 2021 年 4 月 29 日
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!
Find more on Math Operations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!