<html><body><div style="color:#000; background-color:#fff; font-family:Courier New, courier, monaco, monospace, sans-serif;font-size:10pt"><div style="font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 24px;"><span style="font-size: 13px; font-family: verdana, helvetica, sans-serif;">Thanks Pierre-Aimé Agnel for the precise answer. Also I'd like to know what is difference between:</span></div><div style="font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: transparent;"><span>1. </span><span style="font-family: 'Courier New', courier, monaco, monospace, sans-serif;">f = [zeros(size(g1, '*')); ones(size(g2, '*'))];</span></div><div style="font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: transparent;">and,</div><div style="font-family: HelveticaNeue, 'Helvetica Neue', Helvetica,
 Arial, 'Lucida Grande', sans-serif; background-color: transparent;"><span style="background-color: transparent;">2. </span><span style="background-color: transparent; font-family: 'Courier New', courier, monaco, monospace, sans-serif;">f = [zeros(g1); ones(g2)];</span></div><div style="background-color: transparent;"><span style="background-color: transparent;"><br></span></div><div style="font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: transparent;"><span style="background-color: transparent;">In second case, we can also use</span></div><div><span></span></div><div style="background-color: transparent; color: rgb(0, 0, 0); font-size: 13px; font-style: normal;"><span style="background-color: transparent;"><span><span style="font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;">line #8 : </span>t = -20:.1:5; t = t';</span></span></div><div
 style="background-color: transparent; color: rgb(0, 0, 0); font-size: 13px; font-style: normal;"><span style="background-color: transparent;"><span style="font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;">Also why the graph is not same in both cases(either or not including line #8)?</span></span></div><div style="background-color: transparent; color: rgb(0, 0, 0); font-size: 13px; font-style: normal; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"><span style="background-color: transparent;"><span style="font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;">In fact using 2nd definition of f in the code and remaininig all other lines intact gives better plot.</span></span></div><div class="yahoo_quoted" style="display: block;"> <div style="font-family: 'Courier New', courier, monaco, monospace, sans-serif; font-size: 10pt;">
 <div style="font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12pt;"> <div dir="ltr"> <font size="2" face="Arial"> On Monday, April 14, 2014 6:27 PM, Pierre-Aimé Agnel <pierre-aime.agnel@scilab-enterprises.com> wrote:<br> </font> </div>  <div class="y_msg_container"><div id="yiv5350682006"><div>
    Hi everyone,<br clear="none">
    <br clear="none">
    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 clear="none">
    <br clear="none">
    Try this<br clear="none">
    <tt>t1 = -10:.1:0; t1 = t1';</tt><tt><br clear="none">
    </tt><tt>g1 = -2*exp(2*t1);</tt><tt><br clear="none">
    </tt><tt>t2 = 0:.1:10; t2 = t2';</tt><tt><br clear="none">
    </tt><tt>g2 = 2*exp(-t2);</tt><tt><br clear="none">
    </tt><tt>t = [t1; t2]; g = [g1; g2];</tt><tt><br clear="none">
    </tt><tt>f = [zeros(size(g1, '*')); ones(size(g2, '*'))];</tt><tt><br clear="none">
    </tt><tt>c = 0.1*convol(f, g);</tt><tt><br clear="none">
    </tt><tt>//t = -20:.1:5; t = t';</tt><tt><br clear="none">
    </tt><tt>plot(t, c(1:length(t)))</tt><tt><br clear="none">
    </tt><br clear="none">
    See the call of <a rel="nofollow" shape="rect" target="_blank" href="http://help.scilab.org/docs/5.5.0/en_US/ones.html">ones</a>
    and <a rel="nofollow" shape="rect" target="_blank" href="http://help.scilab.org/docs/5.5.0/en_US/zeros.html">zeros</a>
    with matrix (and the synopsis of <a rel="nofollow" shape="rect" target="_blank" href="http://help.scilab.org/docs/5.5.0/en_US/size.html">size</a>).<br clear="none">
    Compare <br clear="none">
    <tt>f = [zeros(size(g1, '*')); ones(size(g2, '*'))];</tt><tt><br clear="none">
      size(f)</tt><br clear="none">
    <br clear="none">
    and the initial<br clear="none">
    <tt>f = [zeros(size(g1)); ones(size(g2))];</tt><tt><br clear="none">
      size(f)</tt><br clear="none">
    <br clear="none">
    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 clear="none">
    <br clear="none">
    Best,<br clear="none">
    <br clear="none">
    <div class="yiv5350682006yqt4542303036" id="yiv5350682006yqtfd76791"><div class="yiv5350682006moz-cite-prefix">On 04/14/2014 02:42 PM, Samuel Gougeon
      wrote:<br clear="none">
    </div>
    </div><blockquote type="cite"><div class="yiv5350682006yqt4542303036" id="yiv5350682006yqtfd11145">Le
      14/04/2014 14:27, Shantanu Dutta a écrit :
      <br clear="none">
      <blockquote type="cite">Hello everyone!
        <br clear="none">
        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 clear="none">
        My code is as follows(Numbers at begining are line no.s):
        <br clear="none">
        <br clear="none">
        1. t1=-10:.1:0;t1=t1';
        <br clear="none">
        2. g1=-2*exp(2*t1);
        <br clear="none">
        3. t2=0:.1:10;t2=t2';
        <br clear="none">
        4. g2=2*exp(-t2);
        <br clear="none">
        5. t=[t1;t2];g=[g1;g2];
        <br clear="none">
        6. f=[zeros(size(g1));ones(size(g2))];
        <br clear="none">
      </blockquote>
      <br clear="none">
      f = [zeros(g1); ones(g2)];
      <br clear="none">
      // should make your script working
      <br clear="none">
      <br clear="none">
      HTH
      <br clear="none">
      Samuel
      <br clear="none">
      <br clear="none">
      _______________________________________________
      <br clear="none">
      users mailing list
      <br clear="none">
      <a rel="nofollow" shape="rect" class="yiv5350682006moz-txt-link-abbreviated" ymailto="mailto:users@lists.scilab.org" target="_blank" href="mailto:users@lists.scilab.org">users@lists.scilab.org</a>
      <br clear="none">
      <a rel="nofollow" shape="rect" class="yiv5350682006moz-txt-link-freetext" target="_blank" href="http://lists.scilab.org/mailman/listinfo/users">http://lists.scilab.org/mailman/listinfo/users</a></div>
      <br clear="none">
    </blockquote>
    <br clear="none">
    <pre class="yiv5350682006moz-signature">-- 
Pierre-Aimé Agnel
Developpment Team
-----------------------------------------------------------
Scilab Enterprises
143bis rue Yves Le Coz - 78000 Versailles, France
Phone: +33.1.80.77.04.68
<a rel="nofollow" shape="rect" class="yiv5350682006moz-txt-link-freetext" target="_blank" href="http://www.scilab-enterprises.com/">http://www.scilab-enterprises.com</a><div class="yiv5350682006yqt4542303036" id="yiv5350682006yqtfd30889"> </div></pre><div class="yiv5350682006yqt4542303036" id="yiv5350682006yqtfd24186">
  </div></div></div><br><div class="yqt4542303036" id="yqtfd31194">_______________________________________________<br clear="none">users mailing list<br clear="none"><a shape="rect" ymailto="mailto:users@lists.scilab.org" href="mailto:users@lists.scilab.org">users@lists.scilab.org</a><br clear="none"><a shape="rect" href="http://lists.scilab.org/mailman/listinfo/users" target="_blank">http://lists.scilab.org/mailman/listinfo/users</a><br clear="none"></div><br><br></div>  </div> </div>  </div> </div></body></html>