【问题标题】:what is Octave equivalent of "freqspace" function of Matlab?什么是 Matlab 的“freqspace”函数的 Octave 等效项?
【发布时间】:2018-09-03 08:28:18
【问题描述】:

在 Matlab 中我们可以写,

[u, v] = freqspace(size(I),'meshgrid');

什么是 Octave 等价于 Matlab 的“freqspace”函数?

【问题讨论】:

    标签: matlab octave


    【解决方案1】:

    如您所见,freqspace 未在 Octave 中实现:

    >> help freqspace
    error: help: the 'freqspace' function is not yet implemented in Octave
    
    Please read <http://www.octave.org/missing.html> to learn how you can
    contribute missing functionality.
    

    查看 MATLAB 函数的 documentation page,您会得到:

    语法

    [f1,f2] = freqspace(n)
    [f1,f2] = freqspace([m n])
    [x1,y1] = freqspace(...,'meshgrid')
    f = freqspace(N)
    f = freqspace(N,'whole')
    

    说明 freqspace 返回等间隔频率响应的隐含频率范围。 freqspace 在创建时很有用 各种一维和二维所需的频率响应 应用程序。

    [f1,f2] = freqspace(n) 返回二维频率向量 f1f2 用于 n×n 矩阵。

    对于 n 奇数,f1f2 都是 [-n+1:2:n-1]/n

    对于nf1f2 都是[-n:2:n-2]/n

    [f1,f2] = freqspace([m n]) 返回二维频率 向量f1f2 用于m-by-n 矩阵。

    [x1,y1] = freqspace(...,'meshgrid') 等价于

    [f1,f2] = freqspace(...);
    [x1,y1] = meshgrid(f1,f2);
    

    f = freqspace(N)返回一维频率向量f 假设N 围绕单位圆均匀分布点。对于N 甚至 或者奇怪,f(0:2/N:1)。对于 N 偶数,freqspace 因此返回 (N+2)/2 积分。对于N奇数,它返回(N+1)/2点。

    f = freqspace(N,'whole') 返回 N 周围均匀分布的点 整个单位圆。在这种情况下,f0:2/N:2*(N-1)/N

    基于此,我整理了以下函数。虽然它完成得非常快,并没有涵盖所有案例,但实施的案例似乎在 Octave 中运行良好。希望这能给你一个开始的想法:

    function varargout = freqspace(varargin)
    
      if nargin==1 && nargout==2 % [f1,f2] = freqspace(n)
        n = varargin{1};
    
        if mod(n,2)==0 % n is even
          varargout{1} = [-n:2:n-2]/n;
          varargout{2} = [-n:2:n-2]/n;
        else % n is odd
          varargout{1} = [-n+1:2:n-1]/n;
          varargout{2} = [-n+1:2:n-1]/n;
        end
    
      elseif nargin==1 && nargout==1 % f = freqspace(N)
        N = varargin{1};
        varargout{1} = (0:2/N:1);
    
      elseif nargin==2 && nargout==1 % f = freqspace(N,'whole')
        N = varargin{1};
        if ~ischar(varargin{2}) || ~strcmpi(varargin{2},'whole')      
          error('The correct syntax is f = freqspace(N,''whole'')');
        else
          varargout{1} = 0:2/N:2*(N-1)/N;
        end
    
      else  
        disp('Case not yet implemented.')
        return
    
      end
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-09-19
      • 1970-01-01
      • 1970-01-01
      • 2022-01-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多