I want to plot a line but got a curve

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 Commenti

How did you plot? Show us the code and picture.
What shows up for unique(diff(a))
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.

Accedi per commentare.

 Risposta accettata

KSSV
KSSV il 21 Ago 2020
t = (0:0.01:0.64)' ;
a = -9.81*ones(size(t)) ;
plot(t,a)

Più risposte (1)

Just
t = (0:0.01:0.64)';
a = -9.81*ones(size(t));
plot(t,a)
gives a horizontal line.

Categorie

Scopri di più su 2-D and 3-D Plots in Centro assistenza e File Exchange

Tag

Richiesto:

il 21 Ago 2020

Commentato:

il 21 Ago 2020

Community Treasure Hunt

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

Start Hunting!

Translated by