Error using plot Invalid first data argument.
3 views (last 30 days)
Walter Roberson on 19 Jun 2021
MATLAB has a feature known as "command / function duality".
Any time you see a line of the form
WORD1 WORD2 .... WORDN
and there is no ( between WORD1 and the remainder of the expression, and WORD2 is not an assignment operator, then MATLAB understand that you are making a function call, and it converts the arguments into quoted strings.
is converted into the function call
and then you have the problem that 'TCO' is not a valid first argument for plot()
You see this kind of conversion a fair bit, but they tend to go unnoticed. For example,
is treated as a function call
There is no special processing to recognize hold specifically as a command; hold is not one of the special keywords known to MATLAB such as break or case : MATLAB just has a rule that says "no ( between what looks like a function name and what might be an argument? Convert the words into quoted strings and call the function with those!"
Anyhow, you want
but now you know more about why it happened.