Plotting only the positive radius for a polar graph
9 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
MuhammadAqdas110
el 13 de Oct. de 2020
Comentada: MuhammadAqdas110
el 15 de Oct. de 2020
I want to plot a few polar curves, but I want MATLAB to ignore the negative values my function outputs for r. How can I do so?
EDIT: Figured out a way to do it through the following code
theta = 0:0.01:2*pi;
r = sin(2*theta);
for i=1:1:629
if r(1,i) < 0
r(1,i) = 0;
else r(1,i) = r(1,i);
i = i+1;
end
end
polarplot(theta,r);
Is there a more efficient way to go about this though?
0 comentarios
Respuesta aceptada
Adam Danz
el 13 de Oct. de 2020
Editada: Adam Danz
el 14 de Oct. de 2020
"Is there a more efficient way to go about ths?"
Yes❕
All of that in the loop can be done with this one line,
r(r<0) = 0;
or, if you'd like to remove those values from the plot,
r(r<0) = NaN;
or if you'd like to remove those values completely,
theta(r<0) = [];
r(r<0) = [];
Más respuestas (0)
Ver también
Categorías
Más información sobre Polar 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!