[英]what is Octave equivalent of "freqspace" function of Matlab?
在Matlab中,我們可以寫,
[u, v] = freqspace(size(I),'meshgrid');
八度等效於 Matlab 的“freqspace”函數是什么?
正如您所發現的,在 Octave 中沒有實現freqspace
:
>> 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 函數的文檔頁面,您會得到:
句法
[f1,f2] = freqspace(n) [f1,f2] = freqspace([mn]) [x1,y1] = freqspace(...,'meshgrid') f = freqspace(N) f = freqspace(N,'whole')
說明
freqspace
返回等間隔頻率響應的隱含頻率范圍。 freqspace 在為各種一維和二維應用創建所需的頻率響應時很有用。
[f1,f2] = freqspace(n)
返回 n×n 矩陣的二維頻率向量f1
和f2
。對於
n
奇數,f1
和f2
都是[-n+1:2:n-1]/n
。對於
n
偶數,f1
和f2
都是[-n:2:n-2]/n
。
[f1,f2] = freqspace([mn])
返回m
×n
矩陣的二維頻率向量f1
和f2
。
[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
均勻分布的點。 在這種情況下,f
是0: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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.