A unknown bug on matrix
이전 댓글 표시

Follow the fig, R and S are matrix of size(4225*4225), delta, sigma,delta_gamma are scale parameter.
When they minus, the size should still be 4225*4225. However when there is a space behind '-' , size becoms 4225*8450.
댓글 수: 2
Stephen23
2023년 6월 5일
"A unknown bug on matrix"
The more important question is: why are you using completely superfluous square brackets, when you are not concatenating anything together?
Square brackets are a concatenation operator.
But apparently you are not intending to concatenate anything together....
So why use square brackets?
Ziwen Gu
2023년 6월 5일
채택된 답변
추가 답변 (2개)
KSSV
2023년 6월 5일
0 개 추천
This is not bug....don't use the sqaure braces.
If you are using square braces, than space is considered as a different element.
Satwik
2023년 6월 5일
0 개 추천
The reason for this is that on adding space before '-', MATLAB interprets it as concatenation instead of subtraction. That is the reason the size is doubled. The second line is negating the values of delta*sigma*S and concatenating with R/delta_gamma. So, you cannot give a space before the '-'.
댓글 수: 2
"The reason for this is that on adding space before '-', MATLAB interprets it as concatenation instead of subtraction."
In general this is not correct. In some specific situations within the concatenation operators (i.e. square brackets) this might be the effect observed. But a more accurate description is that unary negation has a higher priority than binary subtraction, just as the MATLAB documentation explains:
"So, you cannot give a space before the '-'."
Really? It works for me:
3 - 1 % a space before the -
Ziwen Gu
2023년 6월 5일
카테고리
도움말 센터 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!