Trouble with surf
9 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I am trying to plot the surface of a sphere but keep running into trouble in the z variable of my code. I have tried to resize the ra variable to the same size as y and x by multiplying it by a ones vector before sending it into z. I have tried carrying out the operations in z with element wise power . and without. I am actually pretty disappointed in myself that I can not seem to figure out an easy problem such as this. I have it sized right now but z keeps getting imaginary numbers which the system will not plot. The length of ra and theta were predetermined to be 10 and 22. Here is what I have so far. Thanks in advance for any help provided.
theta=linspace(0,2*pi,22)
ra=linspace(0,1,10)
x=(ra'*cos(theta))
y=(ra'*sin(theta))
r1=ones(22,1)*ra
r2=r1'
z=abs(sqrt(r2.^2-x.^2-y.^2))
surf(x,y,z)
0 comentarios
Respuesta aceptada
Andreas Goser
el 7 de Feb. de 2012
Your code executes fine on my machine. z is not complex in my case.
One idea I have is, that you have multiple ABS functions on you path.
which abs -all
Should just return paths to MATLAB builtin functions. Please verify.
Más respuestas (0)
Ver también
Categorías
Más información sobre Surface and Mesh Plots 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!