Doubt in plot3d

classic Classic list List threaded Threaded
5 messages Options
Lucio Agostinho Rocha Lucio Agostinho Rocha
Reply | Threaded
Open this post in threaded view
|

Doubt in plot3d

Hi,

I'm trying to plot the following function in Scilab:

x=[-1:0.01:1];
y=[-1:0.01:1];
g = x .* sin(4 .* %pi .* x) - y .* sin ( 4 .* %pi .* y + %pi ) + 1;
plot3d(x,y,g)

but nothing is displayed. What i'm doing wrong? Someone could help me? If yes, how can I put a degrade with several colors?

Thanks in advance,

Lucio
........



Veja quais são os assuntos do momento no Yahoo! + Buscados: Top 10 - Celebridades - Música - Esportes
ycollet ycollet
Reply | Threaded
Open this post in threaded view
|

Re: Doubt in plot3d

Try this:

x=[-1:0.01:1];
y=[-1:0.01:1];

for i=1:length(x)
  for j=1:length(y)
    g(i,j) = x(i) .* sin((4*%pi) * x(i)) - y(j) .* sin ( (4*%pi) *  y(j)
+ %pi ) + 1;
  end
end
 
plot3d(x,y,g)

YC
 
Lucio Agostinho Rocha a écrit :

> Hi,
>
> I'm trying to plot the following function in Scilab:
>
> x=[-1:0.01:1];
> y=[-1:0.01:1];
> g = x .* sin(4 .* %pi .* x) - y .* sin ( 4 .* %pi .* y + %pi ) + 1;
> plot3d(x,y,g)
>
> but nothing is displayed. What i'm doing wrong? Someone could help me?
> If yes, how can I put a degrade with several colors?
>
> Thanks in advance,
>
> Lucio
> ........
>
>
> ------------------------------------------------------------------------
> Veja quais são os assuntos do momento no Yahoo! + Buscados: Top 10
> <http://br.rd.yahoo.com/mail/taglines/mail/*http://br.maisbuscados.yahoo.com/>
> - Celebridades
> <http://br.rd.yahoo.com/mail/taglines/mail/*http://br.maisbuscados.yahoo.com/celebridades/>
> - Música
> <http://br.rd.yahoo.com/mail/taglines/mail/*http://br.maisbuscados.yahoo.com/m%C3%BAsica/>
> - Esportes
> <http://br.rd.yahoo.com/mail/taglines/mail/*http://br.maisbuscados.yahoo.com/esportes/>



Christian Vincent Christian Vincent
Reply | Threaded
Open this post in threaded view
|

Re: Doubt in plot3d

In reply to this post by Lucio Agostinho Rocha
Lucio Agostinho Rocha a écrit :

> Hi,
>
> I'm trying to plot the following function in Scilab:
>
> x=[-1:0.01:1];
> y=[-1:0.01:1];
> g = x .* sin(4 .* %pi .* x) - y .* sin ( 4 .* %pi .* y + %pi ) + 1;
> plot3d(x,y,g)
>
> but nothing is displayed. What i'm doing wrong? Someone could help me?
> If yes, how can I put a degrade with several colors?
>
> Thanks in advance,
>
> Lucio
> ........
>
>
> ------------------------------------------------------------------------
> Veja quais são os assuntos do momento no Yahoo! + Buscados: Top 10
> <http://br.rd.yahoo.com/mail/taglines/mail/*http://br.maisbuscados.yahoo.com/>
> - Celebridades
> <http://br.rd.yahoo.com/mail/taglines/mail/*http://br.maisbuscados.yahoo.com/celebridades/>
> - Música
> <http://br.rd.yahoo.com/mail/taglines/mail/*http://br.maisbuscados.yahoo.com/m%C3%BAsica/>
> - Esportes
> <http://br.rd.yahoo.com/mail/taglines/mail/*http://br.maisbuscados.yahoo.com/esportes/>

=========
You can also try
x=[-1:0.01:1];
y=[-1:0.01:1];
deff("z=g(x,y)","z = x .* sin(4 .* %pi .* x) - y .* sin ( 4 .* %pi .* y
+ %pi ) + 1")
fplot3d(x,y,g)
=========
ChV



Ronald Michaels Ronald Michaels
Reply | Threaded
Open this post in threaded view
|

Re: Doubt in plot3d

In reply to this post by Lucio Agostinho Rocha
Hi -

I think the problem lies with g.  Try this code in order to see what you
are actually doing:


clear
x=[-1:0.01:1];
y=[-1:0.01:1];
g = x .* sin(4 .* %pi .* x) - y .* sin ( 4 .* %pi .* y + %pi ) + 1;
size(g)
plot(g)


Ron


On Sat, 2009-05-16 at 22:13 -0700, Lucio Agostinho Rocha wrote:
> x=[-1:0.01:1];
> y=[-1:0.01:1];
> g = x .* sin(4 .* %pi .* x) - y .* sin ( 4 .* %pi .* y + %pi ) + 1;
> plot3d(x,y,g)
>


Samuel GOUGEON-3 Samuel GOUGEON-3
Reply | Threaded
Open this post in threaded view
|

Re: Doubt in plot3d

In reply to this post by Lucio Agostinho Rocha
Hi,

Lucio Agostinho Rocha <[hidden email]> a écrit :

> Hi,
>
> I'm trying to plot the following function in Scilab:
>
> x=[-1:0.01:1];
> y=[-1:0.01:1];
> g = x .* sin(4 .* %pi .* x) - y .* sin ( 4 .* %pi .* y + %pi ) + 1;
> plot3d(x,y,g)
>
> but nothing is displayed. What i'm doing wrong? Someone could help  
> me? If yes, how can I put a degrade with several colors?

x as well as y must be matrices for calculating g in this way:
clf;
X=[-1:0.01:1];
Y=[-1:0.01:1];
x=ones(length(Y),1)*X;
y=Y'*ones(1,length(X));
g = x .* sin(4 .* %pi .* x) - y .* sin ( 4 .* %pi .* y + %pi ) + 1;
plot3d(X,Y,g)

should work and fairly uses Scilab's efficiency for internal matrix
calculation

Regards
Samuel