Error using min. Matrix dimensions must agree.

조회 수: 1 (최근 30일)
Gavriel Fleurov
Gavriel Fleurov 2020년 3월 6일
편집: Gavriel Fleurov 2020년 3월 6일
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
Stephen23
Stephen23 2020년 3월 6일
편집: Stephen23 2020년 3월 6일
"...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).
Gavriel Fleurov
Gavriel Fleurov 2020년 3월 6일
Got it, thanks!

댓글을 달려면 로그인하십시오.

채택된 답변

the cyclist
the cyclist 2020년 3월 6일
편집: the cyclist 2020년 3월 6일
You just need to be a bit more careful with the syntax. Take a look at the documentation.
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.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by