Info

此问题已关闭。 请重新打开它进行编辑或回答。

how can use this filtered function pleas?

1 次查看(过去 30 天)
mary noor
mary noor 2015-3-1
关闭: MATLAB Answer Bot 2021-8-20
i have this subprogram to filter
g2 = zeros(K,N,M); %variables are (s,u,w)
b = pi/delta_u; % Nyquist frequency
bs = [-N:N]*delta_u; % 2N+1 points
kernel = slkernel(bs,1/b);
for m=1:K, % s-loop
for j=1:M, % w-loop
g_filt = conv(kernel,g1(m,:,j)); % length 3N
g2(m,:,j) = g_filt(N+1:2*N); % take middle N samples
end
end
function [k] = slkernel(s,r)
s = s/r;
k = zeros(size(s));
% if denominator is small, return 1/pi
small = abs((pi/2)^2-s.^2)<=1.e-6; % indices of small denominators
k(small) = ones(size(k(small)))/pi;
not_small = abs((pi/2)^2-s.^2)>1.e-6; % indices of not small denoms
t = s(not_small);
k(not_small)=1/(r^2)*1/(2*pi^3)*(pi/2 - t.*sin(t))./((pi/2)^2 - t.^2);
need to more window filter to g2(m,:,j)by using this filter
function [filt, order] = Filternoor(filter, len, d)
order = max(64,2^nextpow2(2*len));
filt = 2*( 0:(order/2) )./order;
w = 2*pi*(0:size(filt,2)-1)/order; % frequency axis up to Nyquist
w1 = (0:size(filt,2)-1)/order; %of suggest
switch lower(filter)
case 'ram-lak'
% Do nothing
case 'shepp-logan'
% be careful not to divide by 0:
filt(2:end) = filt(2:end) .* (sin(w(2:end)/(2*d))./(w(2:end)/(2*d)));
case 'cosine'
filt(2:end) = filt(2:end) .* cos(w(2:end)/(2*d));
case 'hamming'
filt(2:end) = filt(2:end) .* (.54 + .46 * cos(w(2:end)/d));
case 'hann'
filt(2:end) = filt(2:end) .*(1+cos(w(2:end)./d)) / 2;
case 'suggest-filter'
filt(2:end) = (filt(2:end)) .*(cos(2.*w1(2:end)/(d))).^5.3;
to became the subprogram as
len=128;
d=1;
order = max(64,2^nextpow2(2*len));
filt = 2*( 0:(order/2) )./order;
w = 2*pi*(0:size(filt,2)-1)/order;
g2 = zeros(K,N,M); %variables are (s,u,w)
b = pi/delta_u; % Nyquist frequency
% % bs = [-N:N]*delta_u; % 2N+1 points
kernel = slkernel(w,1/b);
for m=1:K, % s-loop
for j=1:M, % w-loop
g_filt = conv(kernel,g1(m,:,j)); % length 3N
g2(m,:,j) = g_filt(0:128); % take middle N samples
end
end
filtered= 'hann';
filter=Filternoor(filtered,128,1);
g2(m,:,j)= ifft(fft(filter,g2(m,:,j))
but i have dimension mismatch. between matrix pleas help me to matching the matrix and not problem to use convalution or fft. best regards
  1 个评论
Geoff Hayes
Geoff Hayes 2015-3-1
Mary - please include the full error message so that we can get an idea of which line is throwing the error. Also include your inputs K, N*, M, delta_u, etc.

回答(0 个)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by