Error using plot3 Vectors must be the same length.

조회 수: 7 (최근 30일)
Ajay Adithya S
Ajay Adithya S 2020년 9월 28일
답변: KSSV 2020년 9월 28일
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
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
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

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by