[scilab-Users] Creating an vector field

calixte calixte.denizet at ac-rennes.fr
Fri Aug 13 17:40:56 CEST 2010


Hello Pedro,

Le jeudi 12 août 2010 à 15:40 -0700, Pedro Ledoux a écrit :
> Hello
> 
> An supposed charge in in origin. Thus it create a vector field around
> it. This can be obtained from Coulomb's law. When I tried to create
> the vector field caused by this charge I used the commands:
> 
> x=-1:0.1:1;  
> y=x;
> [X Y]=meshgrid(x,y)
> r=sqrt(X.^2+Y.^2)+%eps //I sumed with eps to avoid a error by division
> for 0
> ax=X./r;
> ay=Y./r
> champ(x,y,ax,ay)
> 
> The field that I got with those command lines wasn't what I wanted.
> but using the code bellow Scilab took the correct field.
> 
> x=-1:0.1:1;  
> y=x;
> [Y X]=meshgrid(x,y)
> r=sqrt(X.^2+Y.^2)+%eps //I sumed with eps to avoid a error by division
> for 0
> ax=X./r;
> ay=Y./r
> champ(x,y,ax,ay)
> 
> Acording to manual the first code should give me the correct field. In
> Octave a similar code gave me the correct field. Is seems thar or
> champ or meshgrid function inverted the things in Scilab.
> 
> 

You can compare the results of meshgrid in octave and scilab : they're
the same. So your problem comes from champ. You should read carefully
the help about champ...
For example, in (-1,1)=(x(1),y(21)), you'll find the vector
(ax(1,21),ay(1,21))=(1,-1)/sqrt(2).

In fact, you'll expect to find in point (x(i),y(j)) the vector
(ax(j,i),ay(j,i)) (make a draw)

So the correct command would be : champ(x,y,ax',ay').

Calixte

>  





More information about the users mailing list