How can I import data and save each data category as a separate column in a matrix?
조회 수: 2 (최근 30일)
이전 댓글 표시
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.
댓글 수: 0
채택된 답변
Namnendra
2022년 6월 19일
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.
댓글 수: 0
추가 답변 (0개)
커뮤니티
더 많은 답변 보기: ThingSpeak 커뮤니티
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!