I am trying to numerically differentiate inside a for loop and return a column vector. In short I have a value theta1inv that is solved inside a for loop and I am trying to find the change with respect to time. The time is 0 to 2 with increments of .005 and I am using that as the for loop condition.
Theta1inv has 401 values in a column vector and I am trying to find the change with repect to time. I have used this but it doesn't make a column vector nor does it work in the for loop. But it does give me the correct values from what I can tell.
thetadot1 = gradient(theta1inv(:)) ./ gradient(tt(:));
If I put (ii) after the thetadot1, I get the error code: "Unable to perform assignment because the left and right sides have a different number of elements." It does give me the correct values but not in a column vector and doesn't work in the for loop.
Lastly, theta1inv gives 1x401 double and thetadot gives 401x1 double.