Azzera filtri
Azzera filtri

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

11 visualizzazioni (ultimi 30 giorni)
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?

Risposta accettata

Walter Roberson
Walter Roberson il 26 Feb 2018
Modificato: Walter Roberson il 26 Feb 2018
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 Commenti
Walter Roberson
Walter Roberson il 27 Feb 2018
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.

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by