How to solve 'vector must be the same length', 'functions behave unexpectedly' errors when graphing vector equation

조회 수: 2(최근 30일)
수정 이
수정 이 2020년 9월 18일
댓글: Asad (Mehrzad) Khoddam 2020년 9월 18일
The vector equation is
r(t) = <3, t, 2-t^2>
first of all . I tried
t=linspace(-10,10);
x=3;
y=t;
z=2-(t.^2);
plot3(x,y,z)
I got 'plot3 error' - vector must be the same lengths
Second, I tried
t=linspace(-10,10);
xt=@(t) 3;
yt=@(t) t;
zt=@(t) 2-(t.^2);
fplot3(xt,yt,zt)
I got warning function behaves unexpectedly on array inputs
how can I solve it? I really appreciate any help.
  댓글 수: 1
Asad (Mehrzad)  Khoddam
Asad (Mehrzad) Khoddam 2020년 9월 18일
the code
t=linspace(-10,10);
uses the default number of divisions.
You can use more division like this:
t=linspace(-10,10,51);
% or
t=linspace(-10,10,201);

댓글을 달려면 로그인하십시오.

채택된 답변

Asad (Mehrzad)  Khoddam
Asad (Mehrzad) Khoddam 2020년 9월 18일
in the first code, instead of
x=3;
use this one:
x=3*ones(size(t));

추가 답변(0개)

Community Treasure Hunt

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

Start Hunting!

Translated by