Here is how you define an array and print the first element in it
v = [4 5 6 7];
disp(v(1));
Let not talk about the fact that matlab array starts with 1 for now.
So what's the problem here? The functions also use ()
for receiving parameters. When you read this line without previous lines, disp(v(1))
you have to ask yourself this question:
- v is a function or an array?
"I always read the previous lines" you may argue. But can you remember which one is a function, which one is an array in a long script with many functions and variables?
Now you have to remember ()
has two meanings. Well two usage of ()
near each other can create confusion.
Top comments (2)
Why is MATLAB like this??
Good question. I guess we never know.