Error using min MIN with two matrices to compare and a working dimension is not supported.

11 次查看(过去 30 天)
The code gives me the following error: using min MIN with two matrices to compare and a working dimension is not supported.
The corresponding line in the code:
yp(2) = min(e*f*y(1)/(a+y(1)),(y(3)*f*y(1)/(theta*(a+y(1)))),e*f*theta/y(3))*y(2)-d*y(2);
Could you please help me to fix it?

采纳的回答

Walter Roberson
Walter Roberson 2018-2-26
编辑:Walter Roberson 2018-2-26
Bracket count. Each number indicates the nesting level "after" the bracket above it
yp(2) = min(e*f*y(1)/(a+y(1)),(y(3)*f*y(1)/(theta*(a+y(1)))),e*f*theta/y(3))*y(2)-d*y(2);
1 0 1 2 1 2 3 21,2 3 2 3 2 3 4 5 4321, 2 10 1 0 1 0
notice there are two commas inside the min() level, so you are invoking min() with three arguments. min() has two different syntaxes:
min(ARRAY,ARRAY)
min(ARRAY,[],DIMENSION)
there is no syntax for
min(ARRAY,ARRAY,DIMENSION)
and there is no syntax for
min(ARRAY,ARRAY,ARRAY)
If you need to take the min() amongst three arrays, use
min(min(ARRAY,ARRAY),ARRAY)
or
D = ndims(ARRAY) + 1;
min(cat(D,ARRAY,ARRAY,ARRAY),D)
  3 个评论
Walter Roberson
Walter Roberson 2018-2-27
When you use min(A, B) then it proceeds element by element giving you a result the same size as the original with the pairwise minimum.
When you min(A) which is the same case as min([A;B;C]) then you take the minimum along each column giving you a result that has one row and the same number of columns as the original. Not the same.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Ordinary Differential Equations 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by