Error using plot3 Vectors must be the same length.

7 visualizaciones (últimos 30 días)
Ajay Adithya S
Ajay Adithya S el 28 de Sept. de 2020
Respondida: KSSV el 28 de Sept. de 2020
This is the code I am working with and it shows error, Whats the problem and what can be done to solve it?
t = linspace(-100*pi, 100*pi); %define the range you are plotting over
x = (t-2)/(t+2);
y = sin(t);
z = log(9-t.^2);
plot3(x, y, z);
axis equal
  1 comentario
Pawan Sharma
Pawan Sharma el 28 de Sept. de 2020
Hello Ajay,
You are getting the error as x,y,z are not of the same length. x is a single element vector. if you want to do (t-2)/(t+2) to every elememt use (t-2)./(t+2) The code goes liked this
t = linspace(-100*pi, 100*pi); %define the range you are plotting over
x = (t-2)./(t+2);
y = sin(t);
z = log(9-t.^2);
plot3(x, y, z);
axis equal

Iniciar sesión para comentar.

Respuestas (1)

KSSV
KSSV el 28 de Sept. de 2020
Read about element by element operations.
t = linspace(-100*pi, 100*pi); %define the range you are plotting over
x = (t-2)./(t+2); % <----- element by element divison
y = sin(t);
z = log(9-t.^2);
plot3(x, y, z);
axis equal

Categorías

Más información sobre 2-D and 3-D 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