MATLAB: Problems using trapz() – dimension issue

accelerationdimensionstrapzvelocity

clc
clear all;
Az=load('TEXT PILOT CC LANKLE_converted_1.txt');
Az1=Az(:,1);%looking at the velocity in x first
A = length(Az1);
time = (length(Az1)/40); % the amount of time the device was switched on for
t = 0:(1/40):time; % seperating time properly
Az2=(Az1*9.81);%converting the data into m/s^2
vz = trapz(t,Az2);
plot(vz)
I am trying to integrate discrete data from an accelerometer so that I can plot a graph for the velocity I have attempted this a number of ways including using trapz(). I use the code above but I get the following error,
??? Error using ==> trapz at 59
LENGTH(X) must equal the length of the first non-singleton dimension of Y.
Error in ==> test_velocityusingtrap2 at 10
vz = trapz(t,Az2);
any ideas would be great!

Best Answer

t=linspace(0,time,length(Az2));
Related Question