Plotting QI(y1) PCILA(y2) across time(Years[x])

1 view (last 30 days)
I need to plot QI and PCILA across time, and I need to show 2 curves, QI and PCILA across years.My code is
x = Years;
y = PCILA;
y1 = QIL;
plot (x,y,y1);
Unrecognized function or variable 'Years'.
I am getting the error 'Data must be a single input of y-values or one or more pairs
of x- and y-values.' I am not sure how to do this or how to fix it.
  2 Comments
Lei Hou
Lei Hou on 18 Oct 2021
Hi Krutik,
If IncomeLA and QIL are the same datatype, you could concatenate them to be a matrix and then call plot. For example,
plot(x,[y;y1])
Or you can input multiple x-y paris. For example,
plot(x,y,x,y1)
Plot will display y and y1 in single axes.
If you want to display y and y1 in different subplot. You can construct a timetable and call stackedplot.
tt = timetable(Years,IncomeLA,QIL);
stackedplot(tt)
Hoping this is helpful.
Thanks,
Lei

Sign in to comment.

Answers (0)

Categories

Find more on Line Plots in Help Center and File Exchange

Tags

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!