convolution
CASTalk.com Forum Index CASTalk.com
Discussion of DSP, FPGA, storage and embedded system.
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Google
 
Web castalk.com
convolution

 
Post new topic   Reply to topic    CASTalk.com Forum Index -> DSP
Author Message
leyla
Guest





Posted: Fri Dec 09, 2005 5:16 pm    Post subject: convolution Reply with quote

Hi all.
please help me with this code,I dont know what is my mistake
function[y]=myconv(x,h)
y=zeros(length(h),length(x))
for j=1:length(h)
for i=1:length(x)
if(j>=i)
y(i,j)=x(i)*h(j);
end
end
yn=zeros(1,length(x)+length(h)-1)
Back to top
Jerry Avins
Guest





Posted: Sat Dec 10, 2005 12:09 am    Post subject: Re: convolution Reply with quote

leyla wrote:
Quote:
Hi all.
please help me with this code,I dont know what is my mistake
function[y]=myconv(x,h)
y=zeros(length(h),length(x))
for j=1:length(h)
for i=1:length(x)
if(j>=i)
y(i,j)=x(i)*h(j);
end
end
yn=zeros(1,length(x)+length(h)-1)

You can expect better help by stating what the code is intended to do,
and why you think it fails.

Jerry
--
Engineering is the art of making what you want from things you can get.
ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
Back to top
leyla
Guest





Posted: Sat Dec 10, 2005 1:16 am    Post subject: Reply to Jerry Avins Reply with quote

hi
I intend to write a code in Matlab which convolutes the sequences x[n] an
h[n],i have run this code in Matlab but some errors are there.do i have t
use "else" statement after using "if" ??
Back to top
Jerry Avins
Guest





Posted: Sat Dec 10, 2005 1:16 am    Post subject: Re: Reply to Jerry Avins Reply with quote

leyla wrote:
Quote:
hi
I intend to write a code in Matlab which convolutes the sequences x[n] and
h[n],i have run this code in Matlab but some errors are there.do i have to
use "else" statement after using "if" ??

I don't "do" Matlab, but in every language I know, /something/ must
terminate the IF clause.

An effective way to troubleshoot hardware or code is to "poke it and see
how it wiggles." If you suspect that ELSE might be needed, why not try
it and see?

Jerry

P.S. The proper word, at least in English, is "convolve". Whether one
believes in divine creation or not, species don't evolute.
--
Engineering is the art of making what you want from things you can get.
ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
Back to top
Guest






Posted: Sat Dec 10, 2005 1:16 am    Post subject: Re: Reply to Jerry Avins Reply with quote

Some tips for you....

x[n] and h[n] are 1 dmensional sequences...The output should be
too...You have a 2-D output matrix y(i,j) .
Convolution steps: (flip a sequence, multiply, add)..
Check the formula for convolution...it'd be much simpler than your
version.

Good luck..


leyla wrote:
Quote:
hi
I intend to write a code in Matlab which convolutes the sequences x[n] and
h[n],i have run this code in Matlab but some errors are there.do i have to
use "else" statement after using "if" ??
Back to top
Tim Wescott
Guest





Posted: Sat Dec 10, 2005 1:16 am    Post subject: Re: Reply to Jerry Avins Reply with quote

Jerry Avins wrote:
Quote:
Jerry

P.S. The proper word, at least in English, is "convolve". Whether one
believes in divine creation or not, species don't evolute.

Well, hopefully not in public, at least.

--

Tim Wescott
Wescott Design Services
http://www.wescottdesign.com
Back to top
And Blah Blah Blah
Guest





Posted: Sat Dec 10, 2005 1:16 am    Post subject: Re: Reply to Jerry Avins Reply with quote

leyla wrote:
Quote:
hi
I intend to write a code in Matlab which convolutes the sequences x[n] and
h[n],i have run this code in Matlab but some errors are there.do i have to
use "else" statement after using "if" ??



In matlab if you get errors, a good place to start troble shooting is to
look at the errors. In the code you posted -

function[y]=myconv(x,h)
y=zeros(length(h),length(x))
for j=1:length(h)
for i=1:length(x)
if(j>=i)
y(i,j)=x(i)*h(j);
end
end
yn=zeros(1,length(x)+length(h)-1)

I would expect it to complain straight away about a missing "end".
You've not terminated the big for loop "for j=1:length(h)".
Back to top
Guest






Posted: Sat Dec 10, 2005 1:21 pm    Post subject: Re: Reply to Jerry Avins Reply with quote

leyla <leyla2698@yahoo.com> wrote:
Quote:

hi
I intend to write a code in Matlab which convolutes the sequences x[n] and
h[n],i have run this code in Matlab but some errors are there.do i have to
use "else" statement after using "if" ??

y=filter(h,1,x);
Back to top
Rick Lyons
Guest





Posted: Sun Dec 11, 2005 1:16 am    Post subject: Re: convolution Reply with quote

On Fri, 09 Dec 2005 13:09:17 -0500, Jerry Avins <jya@ieee.org> wrote:

Quote:
leyla wrote:
Hi all.
please help me with this code,I dont know what is my mistake
function[y]=myconv(x,h)
y=zeros(length(h),length(x))
for j=1:length(h)
for i=1:length(x)
if(j>=i)
y(i,j)=x(i)*h(j);
end
end
yn=zeros(1,length(x)+length(h)-1)

You can expect better help by stating what the code is intended to do,
and why you think it fails.

Jerry

Hi,
also the myconv() command looks like
a user-written command. Therefore it may
be doing something unusual.

[-Rick-]
Back to top
 
Post new topic   Reply to topic    CASTalk.com Forum Index -> DSP All times are GMT
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




VoIP Electronics Powered by phpBB