⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fd_function.m

📁 在matlab环境下
💻 M
字号:
function sfz =fd_function(f)
 %[filename, pathname] = uigetfile({'*.c', 'All c-Files (*.c)'; '*.dat', 'All tif-Files (*.dat)';'*.*','All Files (*.*)'},'Select a curve');
    % If "Cancel"  then return
    %if isequal([filename,pathname],[0,0])
      % return
      % end 
   % File = fullfile(pathname,filename);
   % f=strcat(pathname,filename);
    fid = fopen(f,'rt');              % fid为输入文件标识
    tline = fgetl(fid);
    datalen=str2num(tline(3:length(tline)));  % 去tline中从第三个字符到最后一个字符并转换为数字,datalen即为点数
    DataRange=zeros(datalen,2);
    i=0;
    while 1
        i=i+1;
        tline = fgetl(fid);
        if ~ischar(tline)
            break
        end       % 输入tline不为字符,跳出
        divpos=0;
        while 1
            divpos=divpos+1;
            if tline(divpos)==' '
                break
            end
        end
        DataRange(i,1)=str2num(tline(1:divpos));
        DataRange(i,2)=str2num(tline(divpos:length(tline)));      % datarange第一行为x坐标,第二行为y坐标
    end
    fclose(fid);  
   N=i-1;        % Number of points in the curve
   for n=1:N
       z(n)=DataRange(n,1)+DataRange(n,2)*j;  % form a complex function z
   end
   fz=fft(z);                                 % Fourier thransform of z
   sfz=zeros(1,16);                            % pickup savaral coeficeants of low frequency可调整
   for n=1:8
      sfz(n)=fz(n);
   end
   for n=N-7:N
      sfz(n-N+8)=fz(n);
   end
   

   
   

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -