# Error in writing an equation (sin function)

2 visualizaciones (últimos 30 días)
verzhen Ligai el 8 de Mayo de 2016
Comentada: verzhen Ligai el 8 de Mayo de 2016
Hello everyone,
I can't seem to successfully obtain a graph of the following equation: f(x,y)=sin(x)sin(y)/(x*y). I think it's because the equation is written wrongly but I can't seem to figure out what I did wrong.
Thank you.
>> x=linspace(0, 2*pi);
>> y=linspace(0, 2*pi);
>> [X,Y]=meshgrid(x,y);
>> Z=sin(X)*sin(Y)/(X*Y).;
>> meshz(X,Y,Z)
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

Roger Stafford el 8 de Mayo de 2016
Editada: Roger Stafford el 8 de Mayo de 2016
The line
Z=sin(X)*sin(Y)/(X*Y).;
is the trouble. You need dots there:
Z=sin(X).*sin(Y)./(X.*Y);
so as to produce element-by-element operations. As it stands. it is performing matrix multiplication and matrix division which you don’t want here. Also that trailing dot does not belong there.
Also note that at the single point x = 0 and y = 0 you will produce a NaN from a zero-divided-by-zero operation there.
##### 3 comentariosMostrar 1 comentario más antiguoOcultar 1 comentario más antiguo
Walter Roberson el 8 de Mayo de 2016
The diagram shows negative and positive coordinates, but you have only plotted over positive coordinates.
verzhen Ligai el 8 de Mayo de 2016
Oh! that makes sense. You are right!!!

Iniciar sesión para comentar.

### Categorías

Más información sobre Assembly en Help Center y File Exchange.

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by