Hi, I have a set of data points in which I would like to numerically integrate using trap. Rather than just calculate the area under the curve, I would like to plot the integral with respect to time. So what I am trying to do is perform the integral between two times, increment the time step to integrate and populate a vector with the result so I can plot the integral with time.
Here is the section of code in my program where I am trying to do this. This is only a section of my entire code so it may look a bit incomplete.
%calculate rotational speed of motors.
for i=1:length(z)
for n=1:i
time_interval(i,1)=t(i,1);
func(i,1)=ang_accel(i,1);
end
react_1(i,1)=trapz(time_interval,func)
end
figure
plot(time_interval,react_1)
Right now my code produces an error:
??? Error using ==> permute
ORDER contains an invalid permutation index.
Error in ==> trapz at 44
y = permute(y,perm);
Error in ==> solver at 86
react_1(i,1)=trapz(time_interval,func)
Any suggestions? Thanks!
Windell
