When calling a function or indexing a variable, use parentheses.
1 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
回答(2 个)
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])
0 个评论
Walter Roberson
2023-11-20
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.
0 个评论
另请参阅
类别
在 Help Center 和 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!