t will be a double precision number representing the current "time". t will seldom be an integer during execution
In MATLAB, Variable(expression) on the left hand side of an assignment statement has two possible meanings:
- The expression represents an index into the given variable. Valid indices must be datatype logical, or (obscurely) must be a character or character vector (obscure!), or must be numeric values that are positive integers. Your t is a non-integer double precision scalar, and so is not a valid index; OR
- The expression is a symbolic variable name or (obscurely) a vector of symbolic variable names. In this case, the name does not indicate indexing, and instead indicates that a symbolic function is to be created in which that name is the name of the formal parameter; for example syms x; f(x) = x^2 - 2; In this case, the resulting symbolic function defines a formula rather than indexing
You appear to have tried to use formula definition syntax with a double precision number instead of a symbolic variable.
In this case, the repair is to remove the line. You do not use deltaP in your calculation, so there is no point assigning to it.
The more general solutions would be one of:
and then use deltaP as a variable name; OR
deltaP = @(t) A*sin(w*t)+B;
and then when you use deltaP be sure to pass a parameter to it.
I would suggest that using a plain variable is more likely to be useful for your situation.
Note: you also do not use a number of other variables in your function, such as A B w.