What is the difference between + and .+ explain with example. Suppose i am adding two matrices which is best and what are their roles.

a = [2,3;5,6]
b = [2,5;6,9]
c = a + b
d = a .+ b

댓글 수: 1

"What is the difference between + and .+ explain with example."
The difference is very simple:
  • + is a MATLAB operator (shorthand for the PLUS function),
  • .+ does not exist.
"Suppose i am adding two matrices which is best and what are their roles."
Using the operator that actually exists is more likely to succeed.

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

답변 (1개)

Theree is no ‘.+’ (or ‘.-’) operator. (Using them would throw an error.) The dot operator with multiplication (‘.*’), division (‘./’), and exponentiation (‘.^’) are element-wise (array) operators, as opposed to matrix operators. Seee the documentation section on Array vs. Matrix Operations for details. Addition and subtraction are always element-wise operations.

카테고리

도움말 센터File Exchange에서 Matrix Indexing에 대해 자세히 알아보기

제품

릴리스

R2024a

질문:

2024년 8월 29일

편집:

2024년 8월 29일

Community Treasure Hunt

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

Start Hunting!

Translated by