 Timestamp:
 Apr 30, 2014, 3:56:19 PM (7 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/src/transform_field/signal_spectrum.m
r753 r759 73 73 %% get the variable to process 74 74 Var= DataIn.(Param.TransformInput.VariableName);%variable to analyse 75 if isfield(Param.TransformInput,'IndexRange') 76 IndexRange=Param.TransformInput.IndexRange; 77 switch size(IndexRange,1) 78 case 3 79 Var=Var(IndexRange(1,1):IndexRange(1,2),IndexRange(2,1):IndexRange(2,2),IndexRange(3,1):IndexRange(3,2)); 80 case 2 81 Var=Var(IndexRange(1,1):IndexRange(1,2),IndexRange(2,1):IndexRange(2,2)); 82 case 1 83 Var=Var(IndexRange(1,1):IndexRange(1,2)); 84 end 85 end 75 86 np=size(Var);%dimensions of Var 76 87 if ~isvector(Var) 77 88 Var=reshape(Var,np(1),prod(np(2:end)));% reshape in a 2D matrix with time as first index 78 89 end 79 Var=Varones(np(1),1)*nanmean(Var,1); %substract mean value (excluding NaN) 90 Var=Varones(np(1),1)*nanmean(Var,1); %substract mean value (excluding NaN) 80 91 81 92 %% look for 'time' coordinate … … 117 128 if ~isempty(ind_bad)check_interp 118 129 sample=interp1(Time(ind_good),sample,(Time(1):dx:Time(end))); %interpolated func 130 sample(isnan(sample))=[]; 119 131 end 120 132 spec=pwelch(sample,WindowLength);% calculate spectrum with Welch method … … 144 156 legend({'spectrum','cospectrum t t1'}) 145 157 get(gca,'Unit') 158 sum(specmean) 159 sum(cospecmean) 146 160 if NbPos~=size(Var,2) 147 161 disp([ 'warning: ' num2str(size(Var,2)NbPos) ' NaN sampled removed'])
Note: See TracChangeset
for help on using the changeset viewer.