average - calculating time averaged data in matlab -


i have vector of data (named ydot) , vector of time, when plot ydot versus time, figure sine function periodic, how can calculate time averaged ydot?

the following codes calculate exact values of ydot , time:

t=(2*pi)/(160e6) tspan=linspace(0,2*t,1500) current=linspace(0,1e-6,40); k=1:length(current) f = @(y, t) (current(k)/3.2911e-016)-(2.6151e+009)*sin(y)+(4.8448e+008)*sin(y+0.5697)+(5.2266e+008)*sin((160e6)*t)*cos(y); [t{k}, y{k}] = ode45(f,tspan,2e22); end y1=cell2mat(y); t1=cell2mat(t); k=1:length(tspan) j=1:length(current) ydot(k,j)=(current(j)/3.2911e-016)-(2.6151e+009)*sin(y1(k,j))+(4.8448e+008)*sin(y1(k,j)+0.5697)+(5.2266e+008)*sin((160e6)*t1(k,j))*cos(y1(k,j)); end end 

this gives ydot 40 different currents, following code plot ydot/time specific current(k) (where k=1:40):

plot(t1(:,k),ydot(:,k)) 

if mean 1 assumes time average taking mean of ydot like

x = 0:0.1:10; % define time ydot = sin(x); % data ydot average = mean(ydot); % use mean function time average plot(x, ydot, x, average); % plot both, average (which should approximately 0 sine , ydot vs x 

if not, need specify task more clearly.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -

debian - 500 Error upon login into Plesk Admin - auth.php3? -