Plotting 3D graph in polar coordinates

I'm trying to plot a 3D graph of a function in polar coordinates. The function takes a different form at different values of r. a, b and multiplier are constants I've defined earlier in the code (a=11, b=60, multiplier =-14)
r=0:1:60;
theta=0:pi/30:2*pi;
for i=1:61
r(i)=i-1;
if (r(i)<a)
sigmar(i)=-p_i;
else
sigmar(i)=((1-((b^2)/(r(i)^2)))*multiplier);
end
end
I've been trying to plot the 3D curve using
[x,y]=pol2cart(theta, r);
surf(x,y,sigmar)
but when I run the code, it keeps saying 'Data dimensions must agree.'

2 comentarios

madhan ravi
madhan ravi el 11 de Nov. de 2018
Editada: madhan ravi el 11 de Nov. de 2018
a,p_i,multiplier? provide the datas
Rachel Attwood
Rachel Attwood el 11 de Nov. de 2018
constants that i've defined earlier in the code. have edited the question body

Iniciar sesión para comentar.

 Respuesta aceptada

madhan ravi
madhan ravi el 11 de Nov. de 2018
Editada: madhan ravi el 11 de Nov. de 2018
clear all
r=0:1:60;
theta=0:pi/30:2*pi;
for i=1:61
r(i)=i-1;
if (r(i)<3)
sigmar(i)=-6;
else
sigmar(i)=((1-((7^2)/(r(i)^2)))*-14); %multiplier is a predefined constant
end
end
[x,y]=pol2cart(theta, r);
[X,Y]=meshgrid(x,y);
sigmar=repmat(sigmar,61,1);
surf(X,Y,sigmar)

5 comentarios

madhan ravi
madhan ravi el 11 de Nov. de 2018
note I provided some fake datas to constant alter it according to your needs and experiment with it
Rachel Attwood
Rachel Attwood el 11 de Nov. de 2018
I tried this and I still get the same error: 'data dimensions must agree'
madhan ravi
madhan ravi el 11 de Nov. de 2018
Editada: madhan ravi el 11 de Nov. de 2018
but I got the plot , try clear all at the beginning of the code and try again
Rachel Attwood
Rachel Attwood el 11 de Nov. de 2018
Ah great, thanks. I've got a plot now. It's not quite how I expected it to look, so I'll keep playing around with it.
madhan ravi
madhan ravi el 11 de Nov. de 2018
Anytime :)

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Polar Plots en Centro de ayuda y File Exchange.

Productos

Versión

R2016b

Preguntada:

el 11 de Nov. de 2018

Comentada:

el 11 de Nov. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by