Borrar filtros
Borrar filtros

plot a function in 3D

3 visualizaciones (últimos 30 días)
Dimitris
Dimitris el 12 de Ag. de 2011
I have variables a and b both defined in [-1,+1] and the function c = a / (a + b)
How can I plot c in 3D to visualize the function?

Respuesta aceptada

Walter Roberson
Walter Roberson el 13 de Ag. de 2011
RESOLUTION=20; %increase this for a finer grid
t = linspace(-1,1,RESOLUTION);
[a,b] = ndgrid(t,t);
c = a./(a+b);
surf(a,b,c);
It is, however, not possible to plot it as a continuous surface, as your graphics display only has discretized output locations ("pixels").
  3 comentarios
bym
bym el 13 de Ag. de 2011
why do you think it does not look correct?
Dimitris
Dimitris el 14 de Ag. de 2011
it is correct. the resolution is too coarse and confused me. thanks for your help.

Iniciar sesión para comentar.

Más respuestas (1)

bym
bym el 12 de Ag. de 2011
a= rand(10,1)*2-1
b=rand(10,1)*2-1
c=a./(a+b)
scatter3(a,b,c)
  1 comentario
Dimitris
Dimitris el 12 de Ag. de 2011
thanks, but can I plot it as a continuous surface. For all values, not just random samples?

Iniciar sesión para comentar.

Categorías

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

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by