Circular convolution and Linear convolution in matlab

Posted by izRead
2014.11.28 20:43 Small talk


Circular convolution 

and

Linear convolution in matlab



  In Matlab, there is an implemented convolution functions. In this article, I will introduce some implementation of basic convolutions.



  For random vector x and y, i.e.,


x = rand(1,50) * 100;

y = rand(1,50) * 100;


will create the size-of-50-sequence.



  In this situation, If you want the linear convolution is calculated, Use the implemented function in Matlab,


conv(x,y)


that result convolution sequence will have the size of 50+50-1 = 99.



  There is another function called circular convolution. In general, if you want the circular convolution is exist, then the two sequence that is calculated must have the same size. In this example, x and y have same size. So, there is no problem if you write the next function:


cconv(x,y,50)




And the result like this:


>> cconv(x,y,50)


ans =


   1.0e+04 *


  Columns 1 through 9


    6.0041    5.1575    6.2228    5.9217    4.9539    5.6628    5.1750    5.0270    5.0852


  Columns 10 through 18


    5.0789    4.3921    4.4266    4.8757    4.6072    3.9091    5.1503    4.1280    4.4504


  Columns 19 through 27


    5.3824    4.3557    4.5851    5.3465    4.7554    4.8855    4.4628    4.8166    4.7785


  Columns 28 through 36


    4.4799    5.1233    5.3321    5.1332    5.4593    5.6959    6.2551    6.2619    5.7685


  Columns 37 through 45


    6.0032    6.5611    5.1843    5.9811    5.9483    5.5950    5.6681    5.7450    5.8873


  Columns 46 through 50


    6.0342    4.5957    6.4231    5.7488    5.4506 


>> conv(x,y)


ans =


   1.0e+04 *


  Columns 1 through 9


    5.9217    4.9539    5.6628    5.1750    5.0270    5.0852    5.0789    4.3921    4.4266


  Columns 10 through 18


    6.0032    6.5611    5.1843    5.9811    5.9483    5.5950    5.6681    5.7450    5.8873


  Columns 19 through 27


    0.9401    0.5569    1.6143    2.0805    2.3401    2.8511    2.5645    2.9433    3.5111


  Columns 28 through 36


    2.9003    3.3891    3.4857    3.7566    4.1336    4.9621    5.4632    5.4356    5.7685


  Columns 37 through 45


    6.0032    6.5611    5.1843    5.9811    5.9483    5.5950    5.6681    5.7450    5.8873


  Columns 46 through 54


    6.0342    4.5957    6.4231    5.7488    5.4506    5.0903    6.0041    5.1575    6.2228


  Columns 55 through 63


    5.9217    4.9539    5.6628    5.1750    5.0270    5.0852    5.0789    4.3921    4.4266


  Columns 64 through 72


    4.8757    4.6072    3.9091    5.1503    4.0807    3.9299    4.4423    3.7988    2.9708


  Columns 73 through 81


    3.2661    2.4153    2.0344    1.8983    1.8733    1.2674    1.5797    1.7341    1.8464


  Columns 82 through 90


    1.3766    1.3256    0.7337    0.7919    0.8263     5.0852    5.0789    4.3921    4.4266


  Columns 91 through 99


    5.9217    4.9539    5.6628    5.1750    5.0270    5.0852    5.0789    4.3921    4.4266






저작자 표시
신고
Secret