%% Write a TimeTable of Data
% Write a timetable of data to the first two fields of a channel. The timestamps provided are interpreted as local time.

% Generate random data
dataField1 = randi(10,10,1);
dataField2 = randi(10,10,1);

% Generate timestamps for the data
tStamps = [datetime('now')-minutes(9):minutes(1):datetime('now')]';

% Create timetable
dataTable = timetable(tStamps,dataField1,dataField2);
channelID = 17504; % Change to your channel ID
writeKey  = '23ZLGOBBU9TWHG2H'; % Change to your Write API Key

% Write 10 values to each field of your channel along with timestamps
thingSpeakWrite(channelID,dataTable,'WriteKey',writeKey)

%
% Copyright 2018 The MathWorks, Inc.