could you help me with this explanation?

2 次查看(过去 30 天)
OverallEffectinevess = (MassFlowFunction*ConvectionCoolingEfficiency)/(1 + MassFlowFunction*ConvectionCoolingEfficiency);
MetalTemperature = (ExternalGasTemperature) - OverallEffectinevess*(ExternalGasTemperature-CoolantInletTemperature);
Error using *
Incorrect dimensions for matrix multiplication. Check that the number of columns in the first matrix matches the number of rows in the second matrix. To perform elementwise multiplication, use '.*'.

采纳的回答

James Tursa
James Tursa 2020-5-19
编辑:James Tursa 2020-5-19
It's possible you just need to switch to element-wise operators. E.g.,
OverallEffectinevess = (MassFlowFunction.*ConvectionCoolingEfficiency)./(1 + MassFlowFunction.*ConvectionCoolingEfficiency);
MetalTemperature = (ExternalGasTemperature) - OverallEffectinevess.*(ExternalGasTemperature-CoolantInletTemperature);
What are the sizes of your variables?
  3 个评论
Walter Roberson
Walter Roberson 2020-5-19
In MATLAB, C = A*B is algebraic matrix multiplication, also known as Inner Product.
C(I,J) = sum(A(I,:) .* B(:,J).')
In order for this to work, size(A,2) must be the same as size (B,1)
When you have A is a (10 x 1), B is a (10 x 1), then size(A,2) is 1, and size(B,1) is 10, and 1 is not equal to 10 so that is an error. You could have A*B' giving a 10 x 10 result, or you could have A'*B giving a 1 x 1 result, but not A*B .
If you want to multiple each element by its corresponding element, C(I,J) = A(I,J) * B(I,J) then you need the .* operator, MassFlowFunction.*ConvectionCoolingEfficiency not MassFlowFunction*ConvectionCoolingEfficiency

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Operating on Diagonal Matrices 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by