could you help me with this explanation?

1 view (last 30 days)
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 '.*'.

Accepted Answer

James Tursa
James Tursa on 19 May 2020
Edited: James Tursa on 19 May 2020
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 Comments
Walter Roberson
Walter Roberson on 19 May 2020
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

Sign in to comment.

More Answers (0)

Categories

Find more on Operating on Diagonal Matrices 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!