简单的MATLAB脚本

时间:2017-03-26 18:34:54

标签: arrays matlab fft

我进行了400次实验并得到了一些数据。所以我正在编写一个代码,允许我使用MATLAB读取所有文件,分析它并将结果存储在一个数组中。否则我将不得不单独完成它们,这将永远需要。

代码:

clear
clc
close all

myfolder='C:\Users\Surface\Desktop\New_folder\';
filepattern=fullfile(myfolder,'.txt');
thefiles=dir(filepattern);

for i=1:length(thefiles)
    baseFileName=thefiles(i).name;
    fullFileName=fullfile(myfolder,baseFileName);
    fprintf(1,'Now reading %s\n',fullFileName);
    load(fullFileName);    
    Fs=500; % Samping frequency

    for i=1:n        
        A=Listing(i).name;       
        [t,X,Xrms(i)]=process_data(Listing(i).name);        
    end

    % Extract the data for the time period of [ts tf]    
    ts=0;    
    tf=3;    
    t=t(ts*Fs+1:tf*Fs+1);
    X=X(ts*Fs+1:tf*Fs+1);    
end

% FFT analysis to see the natural frequency
fftplot(1/Fs,X);

% Find the damping ratio
[zeta zeta_m]=finddamping(t,X)

我想知道我哪里出错了。

0 个答案:

没有答案