source: trunk/src/get_field/FFT.m @ 36

Last change on this file since 36 was 36, checked in by sommeria, 14 years ago

-get_field: functions called by ACTION in the GUI get_field put in the subdirectory get_field (like for series)
-help put in the subdir uvmat_doc, help call in uvmat, civ, geometry calib modified accordingly

File size: 2.9 KB
RevLine 
[36]1function GUI_input=FFT(hget_field)
2global spec x_vec
3%requests for the visibility of input windows in the GUI series  (activated directly by the selection in the menu ACTION)
4if ~exist('hget_field','var')
5    GUI_input={'check_1Dplot','y';...%
6        'check_scalar','n';... %
7        'check_vector','n'... %
8               };
9    return %exit the function
10end
11
12%initiation
13hhget_field=guidata(hget_field);
14% testinterp=0;
15abscissa_list=get(hhget_field.abscissa,'String');
16val=get(hhget_field.abscissa,'Value');
17val=val(1);
18abscissa_name=abscissa_list{val};
19ordinate_list=get(hhget_field.ordinate,'String');
20val=get(hhget_field.ordinate,'Value');
21val=val(1); %take only the first variable in the list
22
23%ordinate_name=Field.ListVarName{val};
24ordinate_name=ordinate_list{val};
25
26[Field,errormsg]=read_get_field(hget_field);
27if ~isempty(errormsg)
28    msgbox_uvmat('ERROR',['error in get_field/FFT input:' errormsg])
29    return
30end
31
32% get variable
33eval(['Var= Field.' ordinate_name ';']);
34np=size(Var);
35np_freq=floor(np(1)/2);
36dx=1;%default
37dfreq=1/np(1);%default frequency interval (abscissa= array index)
38if ~isequal(abscissa_name,'')
39    eval(['Coord_x= Field.' abscissa_name ';']);
40    ind_select=find(~isinf(Coord_x));%detect infinite values
41    Coord_x=Coord_x(ind_select);
42    Var=Var(ind_select,:);
43    diff_x=diff(Coord_x);
44    dx=min(diff_x);
45    %interpolate on a regular abscissa interval if needed
46    if (max(diff_x)-dx)> 0.001*dx || numel(ind_select)<np(1)
47        xequ=Coord_x(1):dx:Coord_x(end);%equal time spacingdx=
48        Var=interp1(Coord_x,Var,xequ); %interpolated func
49        np=size(Var);
50    end
51 %   funcinterp=interp1(time,func,timeq); %interpolated func
52    dfreq=1/(Coord_x(end)-Coord_x(1));%frequency interval
53end
54freq_max=1/(2*dx);
55Var=Var-ones(np(1),1)*mean(Var,1); %substract mean value
56fourier=fft(Var);%take fft (complex)
57spec=abs(fourier).*abs(fourier);% take square of the modulus
58spec=spec(1:np_freq,:);%keep only the first half (the other is symmetric)
59
60%plot
61list_fig=get(hhget_field.list_fig,'String');
62val=get(hhget_field.list_fig,'Value');
63hfig=str2num(list_fig{val})% chosen figure number from tyhe GUI
64if isempty(hfig)
65    hfig=figure;
66else
67    figure(hfig);
68end
69haxes=findobj(hfig,'Type','axes');
70if ~isempty(haxes)
71    axes(haxes)
72end
73x_vec=linspace(dfreq,freq_max,np_freq);
74plot(x_vec',spec)
75xlabel('frequency (Hz)')
76ylabel('spectral intensity')
77grid on
78
79%
80%
81% np=length(funcinterp);
82% funcinterp=funcinterp-sum(funcinterp)/np; %substract mean
83% fourier=fft(funcinterp);%take fft (complex)
84% spec=abs(fourier).*abs(fourier);% take sqare of the modulus
85% spec=spec([1:floor(np/2)]);%keep only the first half (the other is symmetric)
86% eval(['Field.' varname '=spec;'])
87% Field
88% % dfreq=1/(time(end)-time(1));%frequency interval
89% % freq=[0:dfreq:(floor(np/2)-1)*dfreq];
90% % figure(1)
91% % hold on
92% % plot(freq,spec)
93% % xlabel('frequency (Hz)')
94% % ylabel('spectral intensity')
95% % title(['spectrum of' fields]);
96% % grid on
97
Note: See TracBrowser for help on using the repository browser.