<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    Hi everyone,<br>
    <br>
    The problem here is that the call to zeros and ones are made with a
    matrix (returned by size(g1) and size(g2)) and thus here<br>
    <br>
    Try this<br>
    <tt>t1 = -10:.1:0; t1 = t1';</tt><tt><br>
    </tt><tt>g1 = -2*exp(2*t1);</tt><tt><br>
    </tt><tt>t2 = 0:.1:10; t2 = t2';</tt><tt><br>
    </tt><tt>g2 = 2*exp(-t2);</tt><tt><br>
    </tt><tt>t = [t1; t2]; g = [g1; g2];</tt><tt><br>
    </tt><tt>f = [zeros(size(g1, '*')); ones(size(g2, '*'))];</tt><tt><br>
    </tt><tt>c = 0.1*convol(f, g);</tt><tt><br>
    </tt><tt>//t = -20:.1:5; t = t';</tt><tt><br>
    </tt><tt>plot(t, c(1:length(t)))</tt><tt><br>
    </tt><br>
    See the call of <a
      href="http://help.scilab.org/docs/5.5.0/en_US/ones.html">ones</a>
    and <a href="http://help.scilab.org/docs/5.5.0/en_US/zeros.html">zeros</a>
    with matrix (and the synopsis of <a
      href="http://help.scilab.org/docs/5.5.0/en_US/size.html">size</a>).<br>
    Compare <br>
    <tt>f = [zeros(size(g1, '*')); ones(size(g2, '*'))];</tt><tt><br>
      size(f)</tt><br>
    <br>
    and the initial<br>
    <tt>f = [zeros(size(g1)); ones(size(g2))];</tt><tt><br>
      size(f)</tt><br>
    <br>
    For the last part, I commented <tt>t</tt> because I think the
    redefinition was wrong (size(t) > size(c)) and caused an index
    error.<br>
    <br>
    Best,<br>
    <br>
    <div class="moz-cite-prefix">On 04/14/2014 02:42 PM, Samuel Gougeon
      wrote:<br>
    </div>
    <blockquote cite="mid:534BD7B1.1040206@free.fr" type="cite">Le
      14/04/2014 14:27, Shantanu Dutta a écrit :
      <br>
      <blockquote type="cite">Hello everyone!
        <br>
        I want to find convolution of two functions using scilab. I've
        seen a book a Matlab solution which I modified to run in scilab.
        <br>
        My code is as follows(Numbers at begining are line no.s):
        <br>
        <br>
        1. t1=-10:.1:0;t1=t1';
        <br>
        2. g1=-2*exp(2*t1);
        <br>
        3. t2=0:.1:10;t2=t2';
        <br>
        4. g2=2*exp(-t2);
        <br>
        5. t=[t1;t2];g=[g1;g2];
        <br>
        6. f=[zeros(size(g1));ones(size(g2))];
        <br>
      </blockquote>
      <br>
      f = [zeros(g1); ones(g2)];
      <br>
      // should make your script working
      <br>
      <br>
      HTH
      <br>
      Samuel
      <br>
      <br>
      _______________________________________________
      <br>
      users mailing list
      <br>
      <a class="moz-txt-link-abbreviated" href="mailto:users@lists.scilab.org">users@lists.scilab.org</a>
      <br>
      <a class="moz-txt-link-freetext" href="http://lists.scilab.org/mailman/listinfo/users">http://lists.scilab.org/mailman/listinfo/users</a>
      <br>
    </blockquote>
    <br>
    <pre class="moz-signature" cols="72">-- 
Pierre-Aimé Agnel
Developpment Team
-----------------------------------------------------------
Scilab Enterprises
143bis rue Yves Le Coz - 78000 Versailles, France
Phone: +33.1.80.77.04.68
<a class="moz-txt-link-freetext" href="http://www.scilab-enterprises.com">http://www.scilab-enterprises.com</a> </pre>
  </body>
</html>