MATLAB Answers

Plotting two random vector

1 view (last 30 days)
eric chung
eric chung on 30 May 2020
Answered: Ameer Hamza on 30 May 2020
This is a very simple question but im having a hard time figuring it out.
Im trying to make a line graph from two vectors.
The first set of data is the x axis points of [1:16] representing week 1 to week 16.
The second set of data is the y axis points of a section of a large data table; the data table goes to 900 rows with 3 columns and i just need the values of rows 816 to 832 in the first column.
I tried various different methods but they all had errors of different kinds.
For such a simple task i find it hard to figure it out. Any help is appreciated thanks!

Answers (1)

Ameer Hamza
Ameer Hamza on 30 May 2020
816 to 832 makes up 17 elements. So I guess the range should be 817 to 832. If the data is available in Table datatype, then you can access it using brace indexing. For example
x = 1:16;
y = T{817:832,1}; % T is name of table
plot(x, y)

Community Treasure Hunt

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

Start Hunting!

Translated by