FFT - find frequency from a time history of displacement
Posted code-saturne
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了FFT - find frequency from a time history of displacement相关的知识,希望对你有一定的参考价值。
fft - find the frequency of a signal
%% inputs: time, displacement, lift and drag coefficents % author: guofei, kaiming ai % output: normalised displacement vs time clear; clc; %% read data data=xlsread(‘gap0.005ur7.xlsx‘); A1=data(800:4233,1); % time on one cycle A2=data(800:4233,2); % displacement A3=data(800:4233,3); % lift A4=data(800:4233,4); % drag % plot(A1,A2) %% plot data figure(1); U=1.1686; %free stream velocity fig_hei=0.28; fig_wei=0.9; lef_cor_x=0.08; lef_cor_y=0.1; % sub-figure1: drag history subplot(3,1,1,‘position‘, [lef_cor_x lef_cor_y+fig_hei+fig_hei fig_wei fig_hei]) plot(A1*U/0.1,A4,‘b-‘); ylabel(‘itC_{D}‘,‘fontsize‘,20,‘fontname‘,‘Times New Roman‘); set(gca,‘fontsize‘,20,‘fontname‘,‘Times New Roman‘) axis([20,400,-inf,inf]) set(gca,‘xticklabel‘,[]) box off ax2 = axes(‘Position‘,get(gca,‘Position‘),... ‘XAxisLocation‘,‘top‘,... ‘YAxisLocation‘,‘right‘,... ‘Color‘,‘none‘,... ‘XColor‘,‘k‘,‘YColor‘,‘k‘); set(ax2,‘YTick‘, []); set(ax2,‘XTick‘, []); box on %sub-figure2: Cl, lift coefficient history subplot(3,1,2,‘position‘, [lef_cor_x lef_cor_y+fig_hei fig_wei fig_hei]) plot(A1*U/0.1,A3,‘r-‘); ylabel(‘itC_{l}‘,‘fontsize‘,20,‘fontname‘,‘Times New Roman‘); set(gca,‘fontsize‘,20,‘fontname‘,‘Times New Roman‘) axis([20,400,-inf,inf]) set(gca,‘xticklabel‘,[]) box off ax2 = axes(‘Position‘,get(gca,‘Position‘),... ‘XAxisLocation‘,‘top‘,... ‘YAxisLocation‘,‘right‘,... ‘Color‘,‘none‘,... ‘XColor‘,‘k‘,‘YColor‘,‘k‘); set(ax2,‘YTick‘, []); set(ax2,‘XTick‘, []); box on %subplot 3: A/D, normalised displacement history subplot(3,1,3,‘position‘, [lef_cor_x lef_cor_y fig_wei fig_hei]) plot(A1*U/0.1,A2/0.1,‘r-‘); ylabel(‘itA/D‘,‘fontsize‘,20,‘fontname‘,‘Times New Roman‘); xlabel(‘ittU/D‘,‘fontsize‘,20,‘fontname‘,‘Times New Roman‘); set(gca,‘fontsize‘,20,‘fontname‘,‘Times New Roman‘) axis([20,400,-inf,inf]) box off ax2 = axes(‘Position‘,get(gca,‘Position‘),... ‘XAxisLocation‘,‘top‘,... ‘YAxisLocation‘,‘right‘,... ‘Color‘,‘none‘,... ‘XColor‘,‘k‘,‘YColor‘,‘k‘); set(ax2,‘YTick‘, []); set(ax2,‘XTick‘, []); box on %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FFT Data_FFT=[A2,A3,A4]; S=[Data_FFT(:,1)-mean(Data_FFT(:,1)),Data_FFT(:,2)-mean(Data_FFT(:,2)),Data_FFT(:,3)-mean(Data_FFT(:,3))]; Fs=200;% sample freq N=9000;% number of sample t=[0:1/Fs:N/Fs]; Y=fft(S,N); Ayy=(abs(Y)); %Ayy=Ayy/(N/2); Ayy_1=Ayy(:,1); % fft of dis Ayy_2=Ayy(:,2); % fft of CL Ayy_3=Ayy(:,3); F=([1:N]-1)*Fs/N; % frequency %%%%%%%% % find peak frequency corresponding to max FFT of dis, Cl, Cd %%%%%%%% XIndex1 = find(Ayy_1 == max(Ayy_1),1, ‘first‘); Ayy_1_max = max(Ayy_1); f_dis = F(XIndex1); % 1st harmonic of displacement %%%%%%%%%% % plot 2 %%%%%%%%%%%%% figure(2); %FFT of cd subplot(3,1,1,‘position‘, [lef_cor_x lef_cor_y+fig_hei+fig_hei fig_wei fig_hei]) plot(F(1:N/2),Ayy_3(1:N/2),‘b-‘,‘linewidth‘,2); ylabel(‘itAmplitude‘,‘fontsize‘,20,‘fontname‘,‘Times New Roman‘); set(gca,‘fontsize‘,20,‘fontname‘,‘Times New Roman‘) axis([0,10,0,inf]) set(gca,‘xticklabel‘,[]) box off ax2 = axes(‘Position‘,get(gca,‘Position‘),... ‘XAxisLocation‘,‘top‘,... ‘YAxisLocation‘,‘right‘,... ‘Color‘,‘none‘,... ‘XColor‘,‘k‘,‘YColor‘,‘k‘); set(ax2,‘YTick‘, []); set(ax2,‘XTick‘, []); box on %FFT of cl subplot(3,1,2,‘position‘, [lef_cor_x lef_cor_y+fig_hei fig_wei fig_hei]) plot(F(1:N/2),Ayy_2(1:N/2),‘b-‘,‘linewidth‘,2); ylabel(‘itAmplitude‘,‘fontsize‘,20,‘fontname‘,‘Times New Roman‘); set(gca,‘fontsize‘,20,‘fontname‘,‘Times New Roman‘) axis([0,10,0,3e3]) set(gca,‘xticklabel‘,[]) box off ax2 = axes(‘Position‘,get(gca,‘Position‘),... ‘XAxisLocation‘,‘top‘,... ‘YAxisLocation‘,‘right‘,... ‘Color‘,‘none‘,... ‘XColor‘,‘k‘,‘YColor‘,‘k‘); set(ax2,‘YTick‘, []); set(ax2,‘XTick‘, []); box on % subplot 3 : dis subplot(3,1,3,‘position‘, [lef_cor_x lef_cor_y fig_wei fig_hei]) plot(F(1:N/2),Ayy_1(1:N/2),‘b-‘,‘linewidth‘,2); xlabel(‘itf‘,‘fontsize‘,20,‘fontname‘,‘Times New Roman‘); ylabel(‘itAmplitude‘,‘fontsize‘,20,‘fontname‘,‘Times New Roman‘); set(gca,‘fontsize‘,20,‘fontname‘,‘Times New Roman‘) axis([0,10,0,100]) box off ax2 = axes(‘Position‘,get(gca,‘Position‘),... ‘XAxisLocation‘,‘top‘,... ‘YAxisLocation‘,‘right‘,... ‘Color‘,‘none‘,... ‘XColor‘,‘k‘,‘YColor‘,‘k‘); set(ax2,‘YTick‘, []); set(ax2,‘XTick‘, []); box on %% mean value of Cd mean_Cd = mean(A4) %% rms_Cd rms_Cd = rms(A4) %% rms_cl rms_Cl = rms(A3) %% displacement A2_mean = A2(A2>0.06); s = sum(A2_mean); l = length(find(A2>0.06)); dis_ave = s/l; %% RMS of displacement, max displacement Rms = rms(A2); dis = Rms*(2)^0.5 max_dis = max (A2) K = F‘; C = data(:,1)*U/0.1;
以上是关于FFT - find frequency from a time history of displacement的主要内容,如果未能解决你的问题,请参考以下文章
在声音文件android上执行dtmf-decoder FFT
Relationship between frequency and spatial in digital images