Error using plot3 Vectors must be the same length.
3 次查看(过去 30 天)
显示 更早的评论
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 个评论
Pawan Sharma
2020-9-28
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
回答(1 个)
KSSV
2020-9-28
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
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!