[scilab-Users] Bug or restriction with matrices?

Daniele Andreucci andreucci at dmmm.uniroma1.it
Fri Jun 5 12:08:36 CEST 2009


Lucio Agostinho Rocha wrote on 06/05/09 04:35:
> Hi,
> 
> I'm working with matrices and I observed this strange behavior. I'd like to acquire as result a matrix with ten lines and ten columns. Then, I tried two things:
> 
> //---Start program
> clear;
> m=zeros(10,10);
> function [] = test()
>     
>   test1(m);
>   
>   m(5,1)=1;
>   disp(m);
> endfunction
> 
> function [] = test1(m)
>   
>   m(5,1)=1;
>   disp(m);
>   
> endfunction
> 
> //---End program
> 
> When I use 'test1' function I acquire the expected result, but when I use only 'test' function, considering 'm' as global, the attribution 'cut' my matrix. Why this occurs?
> 
> Thanks in advance,
> 
> Lucio
> .....
> 
> 

Dear Lucio,

was it because you did not declare

global m;

inside test?

This way it works for me.


If you also declare

global m;

in the main program, m is changed globally.



Daniele



-- 
[ Daniele Andreucci
[ Dip. di Metodi e Modelli Matematici
[ via A. Scarpa 16     00161 Roma, Italy
[ tel.    +39 0649766785
[ fax     +39 064957647
[ e-mail:  andreucci at dmmm.uniroma1.it
[ http://www.dmmm.uniroma1.it/~andreucci/
[ gpg pub key id: D3ADC732

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: OpenPGP digital signature
URL: <https://lists.scilab.org/pipermail/users/attachments/20090605/d8b3eb81/attachment.sig>


More information about the users mailing list