0
votes

Let's assume I have tvector= 1:15 and I have two other vectors : X of size 15, each element of X relates to the corresponding element (element of same index) in t ; and Y of size 5, each element of Y corresponds to t=3,6,9,12,15.

How can I plot Xand Y on the same plot w.r.t. t, though X and Y does not have the same length (especially Y is not of same length as t)

Thanks

1

1 Answers

2
votes

Without an example of what you are trying to achieve, in code, we have to guess at your exact intentions.

However, one option could be to plot a sub-selection of t against Y, something like this (using the values from your example):

plot(t, X, t(3:3:15), Y)

Of course this assumes that your values are actually spaced like your example.

Another option could be to use NaN values as placeholders in the Y vector, to make it the same length as t. You may have to use markers (e.g. 'o') in that case.

The best approach really depends on the context.