Error using plot3 Vectors must be the same length.
조회 수: 7 (최근 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!