Error using min. Matrix dimensions must agree.
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Gavriel Fleurov
el 6 de Mzo. de 2020
Editada: Gavriel Fleurov
el 6 de Mzo. de 2020
Hello,
Perhaps this is a silly question, but I found no suitable answer. I'm having trouble using the 'all' syntax in min/max functions, I have MATLAB R2019a (this shoukd work for 2018b and above).
After having trouble with it, I decided to check it on a simpler matrix. Simply using min/max works as expected. But the following confuses me

Why do the matrix dimensions need to agree? According to the documentation, the 'all' option is to be applied on a single matrix. Furthermore, shouldn't the "1" I wrote be attributed to the dimension along which I want to find the mean? (should give me a 1x4 vector)
Thanks,
Gaby
2 comentarios
Stephen23
el 6 de Mzo. de 2020
Editada: Stephen23
el 6 de Mzo. de 2020
"...but I found no suitable answer."
The documentation explains this, and has examples too.
"According to the documentation, the 'all' option is to be applied on a single matrix."
The max documentation also clearly shows the the dimension / "all" option is the third input argument (not the second input argument like you are doing).
Respuesta aceptada
the cyclist
el 6 de Mzo. de 2020
Editada: the cyclist
el 6 de Mzo. de 2020
max(rand(4),[],'all')
With the syntax you used, MATLAB is trying to interpret that as the two-input version
max(A,B)
where it tries to determine whether A or B has the larger elements.
Más respuestas (0)
Ver también
Categorías
Más información sobre Logical en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!