Why is "hold on" not working?

I am trying to plot multiple helices on 1 graph but I cannot seem to figure it out. Below is my code...
clc;
clear all;
close all;
n = input('number of turns');
a = input('radius');
P = input('pitch angle');
t = 0:pi/50:n*2*pi;
b = a*a*tan(P);
x = a*sin(t);
y = a*cos(t);
z = b*t;
r = 5:pi/50:n*2*pi;
b = a*a*tan(P);
x2 = a*sin(r);
y2 = a*cos(r);
z2 = b*r;
figure(1)
plot3(x,y,z, 'red')
hold on;
figure(2)
plot3(x2,y2,z2, 'blue')
hold off;

 Respuesta aceptada

Geoff Hayes
Geoff Hayes el 11 de Jun. de 2018

0 votos

Julia - are the multiple helices plotted with
plot3(x,y,z, 'red')
and
plot3(x2,y2,z2, 'blue')
If so, then they will display on different figures since you are creating a new figure with figure(2). Try changing your code to
figure(1)
plot3(x,y,z, 'red')
hold on;
plot3(x2,y2,z2, 'blue')

1 comentario

Image Analyst
Image Analyst el 11 de Jun. de 2018
Actually, you can get rid of that call to figure(1) entirely. It's not needed at all.

Más respuestas (0)

La pregunta está cerrada.

Productos

Versión

R2018a

Etiquetas

Preguntada:

el 11 de Jun. de 2018

Cerrada:

el 14 de Jun. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by