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

Pierre-Aimé Agnel pierre-aime.agnel at scilab-enterprises.com
Mon Apr 14 14:56:00 CEST 2014


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 <http://help.scilab.org/docs/5.5.0/en_US/ones.html> 
and zeros <http://help.scilab.org/docs/5.5.0/en_US/zeros.html> with 
matrix (and the synopsis of size 
<http://help.scilab.org/docs/5.5.0/en_US/size.html>).
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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20140414/2bec8927/attachment.htm>


More information about the users mailing list