When calling a function or indexing a variable, use parentheses.
1 view (last 30 days)
Show older comments
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 Comments
Answers (2)
DGM
on 20 Nov 2023
The error message tells you what to do. diag() is a function; [1 2 3] is a vector, so:
diag([1 2 3])
0 Comments
Walter Roberson
on 20 Nov 2023
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 Comments
See Also
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!