result = convn(A,B);
but it is not as fast as i'd like. I want to do this convolution more
like:
A = reshape A to a 2D matrix
B1 = reshape(B,5,1);
result = conv2(A,B);
Could anyone tell me how to reshape/permute A to obtain the same
result?
2. I also want to convolve A with a kernel C (size 1 x 1 x 1 x 5), how
should I modify A, so that I could use conv2 in this case (instead of
convn)?
Thanks!!!!!
bump
Carlos
I think what I want is to use conv2, since my kernels are small and 1-
D. FFT would be slower due to padding and both FFT and IFFT
operations.
On Sep 30, 8:53 am, "Carlos Adrian Vargas Aguilera"
take a look to PERMUTE, and then RESHAPEs
Carlos
A=round(10*rand(50,41,32,63));
B=round(10*rand(1,5,1,1));
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
tic
C=convn(A,B);
toc
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
tic
d=find(size(B)>1);
if length(d)~=1
error('B must have only 1 non-singleton dimension');
end
p=circshift(1:ndims(A),[1 -d+1]);
Ap=permute(A,p);
sC=size(Ap);
Ap=reshape(Ap,size(Ap,1),[]);
C2 = conv2(Ap, B(:));
sC(1)=size(C2,1);
C2 = ipermute(reshape(C2,sC),p);
toc
%%%%%%%%%%%%%%%%%%%%%%%%%%
isequal(C,C2)
% Bruno
i am using the CONV function but it produces the output whose length is
outputlength= inputlength +impluse response length-1
please help me
Use conv2 with the third option instead.
Bruno
con2 gives 2d ans
but i want only 1d
my question is that
let suppose
x[n]=[1 2] %input
h[n]=[4 3 2 1] % impluse response
y[n]=conv(h,x); %
in this case y[n] has length of 5 but i just want that y[n] has same length as input(e.g 2 in this case)
please suggest me some way out of this
thanks
x=[1 2]
h=[4 3 2 1]
y=conv2(h,x,'same')
> this gives the ans y=[11 8 5 2] that has the length of 4 but i just want length of 2.bec inputx[n] has length of 2...
>
Try to think why the above gives length 4, and not 2 nor 5 (=4+2-1).
Bruno