[Scilab-users] Problem using convol() function in scilab

Shantanu Dutta shantanudutta1994 at yahoo.com
Mon Apr 14 18:08:56 CEST 2014


Thanks Pierre-Aimé Agnel for the precise answer. Also I'd like to know what is difference between:
1. f = [zeros(size(g1, '*')); ones(size(g2, '*'))];
and,
2. f = [zeros(g1); ones(g2)];

In second case, we can also use
line #8 : t = -20:.1:5; t = t';
Also why the graph is not same in both cases(either or not including line #8)?
In fact using 2nd definition of f in the code and remaininig all other lines intact gives better plot.
On Monday, April 14, 2014 6:27 PM, Pierre-Aimé Agnel <pierre-aime.agnel at scilab-enterprises.com> wrote:
 
Hi everyone,

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

Try this
t1 = -10:.1:0; t1 = t1';
g1 = -2*exp(2*t1);
t2 = 0:.1:10; t2 = t2';
g2 = 2*exp(-t2);
t = [t1; t2]; g = [g1; g2];
f = [zeros(size(g1, '*')); ones(size(g2, '*'))];
c = 0.1*convol(f, g);
//t = -20:.1:5; t = t';
plot(t, c(1:length(t)))

See the call of ones and zeros with matrix (and the synopsis of size).
Compare 
f = [zeros(size(g1, '*')); ones(size(g2, '*'))];
size(f)

and the initial
f = [zeros(size(g1)); ones(size(g2))];
size(f)

For the last part, I commented t because I think the redefinition was wrong (size(t) > size(c)) and caused an index error.

Best,


On 04/14/2014 02:42 PM, Samuel Gougeon wrote:

Le 14/04/2014 14:27, Shantanu Dutta a écrit : 
>
>Hello everyone! 
>>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. 
>>My code is as follows(Numbers at begining are line no.s): 
>>
>>1. t1=-10:.1:0;t1=t1'; 
>>2. g1=-2*exp(2*t1); 
>>3. t2=0:.1:10;t2=t2'; 
>>4. g2=2*exp(-t2); 
>>5. t=[t1;t2];g=[g1;g2]; 
>>6. f=[zeros(size(g1));ones(size(g2))]; 
>>
>f = [zeros(g1); ones(g2)]; 
>// should make your script working 
>
>HTH 
>Samuel 
>
>_______________________________________________ 
>users mailing list 
>users at lists.scilab.org 
>http://lists.scilab.org/mailman/listinfo/users
>

-- 
Pierre-Aimé Agnel
Developpment Team
-----------------------------------------------------------
Scilab Enterprises
143bis rue Yves Le Coz - 78000 Versailles, France
Phone: +33.1.80.77.04.68 http://www.scilab-enterprises.com

_______________________________________________
users mailing list
users at lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20140414/0f20aad3/attachment.htm>


More information about the users mailing list