When calling a function or indexing a variable, use parentheses.

Hello I am trying to solve this but I need some help to make it work. Kinda new working around matlab. your help would be totally appreciated. Thank you.

回答 (2 件)

DGM
DGM 2023 年 11 月 20 日
The error message tells you what to do. diag() is a function; [1 2 3] is a vector, so:
diag([1 2 3])
ans = 3×3
1 0 0 0 2 0 0 0 3
Walter Roberson
Walter Roberson 2023 年 11 月 20 日

0 投票

The syntax for calling functions is function name followed by ( followed by a list of parameters followed by )
You are trying to use diag[Expressions] -- which would be the kind of calling syntax that Mathematica would use, but not MATLAB.
Use diag([Expressions]) instead.

カテゴリ

ヘルプ センター および File ExchangeMatrix Indexing についてさらに検索

質問済み:

2023 年 11 月 20 日

回答済み:

2023 年 11 月 20 日

Community Treasure Hunt

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

Start Hunting!

Translated by