How can I import data and save each data category as a separate column in a matrix?

2 views (last 30 days)
I am using the ThingSpeak library to import public weather data, and I wanted to tabulate this data as a matrix. I have copied my code and the output below:
data = thingSpeakRead(12397,'Fields',[1,4],NumPoints=50,OutputFormat='TimeTable')
data =
50×2 timetable
Timestamps WindDirectionNorth0Degrees TemperatureF
____________________ __________________________ ____________
18-Jun-2022 19:30:23 105 60.5
18-Jun-2022 19:31:23 210 60.5
18-Jun-2022 19:32:23 92 60.7
18-Jun-2022 19:33:23 148 60.5
18-Jun-2022 19:34:23 192 60.5
18-Jun-2022 19:35:23 162 60.7
18-Jun-2022 19:36:23 118 60.7
18-Jun-2022 19:37:23 171 60.7
18-Jun-2022 19:38:23 145 60.7
: : :
18-Jun-2022 20:11:23 160 59.8
18-Jun-2022 20:12:23 174 59.6
18-Jun-2022 20:13:23 182 59.5
18-Jun-2022 20:14:23 112 59.5
18-Jun-2022 20:15:23 205 59.3
18-Jun-2022 20:16:23 196 59.3
18-Jun-2022 20:17:23 158 59.3
18-Jun-2022 20:18:23 158 59.3
18-Jun-2022 20:19:23 152 59.1
How can I import the data so that each category of data populates a column in a larger matrix? I am looking to create a matrix with WindDirectionNorth0Degrees in one column (this is Field 1), and TemperatureF in another column (this is Field 2), so that I can later plot these two against each other to analyze trends. Thank you all for your time.

Accepted Answer

Namnendra
Namnendra on 19 Jun 2022
You can get the first column and create a nx1 matrix (n is the number of rows). Then you can append the "TemperatureF" column in it.
Array=data.WindDirectionNorth0Degrees;
NewColumn=data.TemperatureF;
Array= [Array NewColumn]; %Array will contain both the columns.

More Answers (0)

Communities

More Answers in the  ThingSpeak Community

Products


Release

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by