I want to plot a line but got a curve

1 回表示 (過去 30 日間)
Jiaqi Wang
Jiaqi Wang 2020 年 8 月 21 日
コメント済み: Jiaqi Wang 2020 年 8 月 21 日
In my data, t = (0:0.01:0.64)', a is a colunm of constants (-9.81) of length 63. I want to plot a vs. t. It's supposed to be a horizontal line, but I got a graph with fluctuations around -9.81. How can I fix this? I used this code:
plot(t(1:length(a)),a)
  3 件のコメント
Walter Roberson
Walter Roberson 2020 年 8 月 21 日
What shows up for unique(diff(a))
Jiaqi Wang
Jiaqi Wang 2020 年 8 月 21 日
Thank you! I think the problem was the calculation kept a long format of the answer of a, which resulted in a minor difference in a.

サインインしてコメントする。

採用された回答

KSSV
KSSV 2020 年 8 月 21 日
t = (0:0.01:0.64)' ;
a = -9.81*ones(size(t)) ;
plot(t,a)

その他の回答 (1 件)

Alan Stevens
Alan Stevens 2020 年 8 月 21 日
Just
t = (0:0.01:0.64)';
a = -9.81*ones(size(t));
plot(t,a)
gives a horizontal line.

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by