Azzera filtri
Azzera filtri

Plot with a lag

5 visualizzazioni (ultimi 30 giorni)
alpedhuez
alpedhuez il 8 Giu 2018
Modificato: Brandon Free il 11 Giu 2018
Suppose I want to have plot of lagged x and y that belong in table T. For example, I want to have a plot that the first element of T.x is paired with second element of T.y, the second element of T.x is paired with the third element of T.y, etc. Please advise.

Risposta accettata

Walter Roberson
Walter Roberson il 8 Giu 2018
plot(T.x(1:end-1), T.y(2:end))

Più risposte (1)

Brandon Free
Brandon Free il 8 Giu 2018
Modificato: Brandon Free il 11 Giu 2018
Because you have to always have the same number of x and y data, you could accomplish this by deleting a few entries. Also note that tables work the same way, meaning you always have to have the same length of x and y, so you first have to transform the tables to regular vectors.
XData = T.x;
YData = T.y;
XData(1) = [];
YData(end) = [];
plot(XData, YData)
  1 Commento
alpedhuez
alpedhuez il 8 Giu 2018
Thank you. Easier to understand.

Accedi per commentare.

Categorie

Scopri di più su 2-D and 3-D Plots in Help Center e File Exchange

Tag

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by