why do error appears such as "Arrays have incompatible sizes for this operation."?

603 次查看(过去 30 天)
Arrays have incompatible sizes for this operation.
Error in fitting_method_iefa (line 238)
Different2 = sum((y-Convolution).^2);
why does this error appears?
  1 个评论
Dyuman Joshi
Dyuman Joshi 2023-5-6
编辑:Dyuman Joshi 2023-5-16
The reason is stated in the error - "Arrays have incompatible sizes for this operation."
For e.g., you can not subtract a 2x3 array from a 3x2 array. Thus, for substraction these arrays have incompatible size.
Check the size of the arrays "y" and "Convolution".

请先登录,再进行评论。

回答(2 个)

Walter Roberson
Walter Roberson 2023-5-16
The story sometimes gets told that originally Loren phrased the error message as "Didn't Think Twice. Wasn't All Right." but that George didn't like The Greatful Dead and made her change the message.

Sourabh
Sourabh 2023-5-15
编辑:Sourabh 2023-5-16
The error "Arrays have incompatible sizes for this operation" in MATLAB occurs when you try to perform operations (such as subtraction) on two arrays that have different sizes or dimensions that are not compatible with each other.
You can understand Array size compatibility from the following link:
Try using the size function to find out the dimensions of an array.
All the best.

类别

Help CenterFile Exchange 中查找有关 Structures 的更多信息

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by