How to correct the invalid expression error when i have the correct delimiters and multiplication operator?
2 views (last 30 days)
I am trying to run this code, but i am getting the invalid expression error for line 6. All parathensis are correct:
Benjamin Kraus on 22 Feb 2022
This is an invalid MATLAB expression:
Specifically, this is invalid:
It is unclear what you intend for MATLAB to do? Should MATLAB multiply a logical vector with the value of f? What is the value of f? If you want MATLAB to do an element-by-element multiplication of the value of (t>=0) with the value of f then you need this:
And this may be invalid, depending on the value of f and t.
In this case (t<1) will be a logical vector and f can either be a function or index. If f is a function, then you are calling that function with a logical vector. If f is a variable, then you will get an invalid index for any value that is less than 1, becase 0 is not a valid index for a MATLAB vector (which is 1-based).