The write channel is same as read channel data. Why the data is not processed?
We collect the real time data from read channel and want process it before sending it to write channel, but the data values in the write channel replicate the read channel values for the following code. Could anyone give suggession how to get the processed data?
% Source ThingSpeak Channel ID for reading data
readChannelID = 2522808; % Replace with your source channel ID
% Destination ThingSpeak Channel ID for writing data
writeChannelID = 2522810; % Replace with your destination channel ID
% ThingSpeak Read API Key for the source channel
readAPIKey = ‘XXX’; % Replace with your read API key
% ThingSpeak Write API Key for the destination channel
writeAPIKey = ‘XXX’; % Replace with your write API key
%% Read Data %%
% Read all available data from the source channel
data = thingSpeakRead(readChannelID, ‘ReadKey’, readAPIKey, ‘Fields’, [1, 2]);
% Extract the values from the read data
values1 = data(:, 1); % Values from field 1 i.e. Estimated Voltage
values2 = data(:, 2); % Values from field 2 i.e. Input Current
% Determine the number of data points retrieved
numPoints = size(data, 1); % Assign the number of rows in the variable ‘data’ to the variable ‘numPoints’
% Generate timestamps for the data
timeStamps = datetime(‘now’) – minutes(numPoints:-1:1);
% Initialize Y arrays
Y1 = zeros(size(values1)); % Create a new array ‘Y1’ filled with zeros that has same size as the array ‘values1’
Y2 = zeros(size(values2)); % Create a new array ‘Y2’ filled with zeros that has same size as the array ‘values2’
% Perform the operation Y(i) = i * I(i) for each value in the read data
for i = 1:length(values1)
disp([‘Processing index ‘, num2str(i)]);
disp([‘values1(‘, num2str(i), ‘) = ‘, num2str(values1(i))]);
disp([‘values2(‘, num2str(i), ‘) = ‘, num2str(values2(i))]);
Y1(i) = i * values1(i);
Y2(i) = i * values2(i);
disp([‘Y1(‘, num2str(i), ‘) = ‘, num2str(Y1(i))]);
disp([‘Y2(‘, num2str(i), ‘) = ‘, num2str(Y2(i))]);
end
% Write the data to the destination channel with timestamps
thingSpeakWrite(writeChannelID, ‘WriteKey’, writeAPIKey, ‘Values’, [Y1′, Y2′], ‘Fields’, [1, 2], ‘Timestamps’, timeStamps);We collect the real time data from read channel and want process it before sending it to write channel, but the data values in the write channel replicate the read channel values for the following code. Could anyone give suggession how to get the processed data?
% Source ThingSpeak Channel ID for reading data
readChannelID = 2522808; % Replace with your source channel ID
% Destination ThingSpeak Channel ID for writing data
writeChannelID = 2522810; % Replace with your destination channel ID
% ThingSpeak Read API Key for the source channel
readAPIKey = ‘XXX’; % Replace with your read API key
% ThingSpeak Write API Key for the destination channel
writeAPIKey = ‘XXX’; % Replace with your write API key
%% Read Data %%
% Read all available data from the source channel
data = thingSpeakRead(readChannelID, ‘ReadKey’, readAPIKey, ‘Fields’, [1, 2]);
% Extract the values from the read data
values1 = data(:, 1); % Values from field 1 i.e. Estimated Voltage
values2 = data(:, 2); % Values from field 2 i.e. Input Current
% Determine the number of data points retrieved
numPoints = size(data, 1); % Assign the number of rows in the variable ‘data’ to the variable ‘numPoints’
% Generate timestamps for the data
timeStamps = datetime(‘now’) – minutes(numPoints:-1:1);
% Initialize Y arrays
Y1 = zeros(size(values1)); % Create a new array ‘Y1’ filled with zeros that has same size as the array ‘values1’
Y2 = zeros(size(values2)); % Create a new array ‘Y2’ filled with zeros that has same size as the array ‘values2’
% Perform the operation Y(i) = i * I(i) for each value in the read data
for i = 1:length(values1)
disp([‘Processing index ‘, num2str(i)]);
disp([‘values1(‘, num2str(i), ‘) = ‘, num2str(values1(i))]);
disp([‘values2(‘, num2str(i), ‘) = ‘, num2str(values2(i))]);
Y1(i) = i * values1(i);
Y2(i) = i * values2(i);
disp([‘Y1(‘, num2str(i), ‘) = ‘, num2str(Y1(i))]);
disp([‘Y2(‘, num2str(i), ‘) = ‘, num2str(Y2(i))]);
end
% Write the data to the destination channel with timestamps
thingSpeakWrite(writeChannelID, ‘WriteKey’, writeAPIKey, ‘Values’, [Y1′, Y2′], ‘Fields’, [1, 2], ‘Timestamps’, timeStamps); We collect the real time data from read channel and want process it before sending it to write channel, but the data values in the write channel replicate the read channel values for the following code. Could anyone give suggession how to get the processed data?
% Source ThingSpeak Channel ID for reading data
readChannelID = 2522808; % Replace with your source channel ID
% Destination ThingSpeak Channel ID for writing data
writeChannelID = 2522810; % Replace with your destination channel ID
% ThingSpeak Read API Key for the source channel
readAPIKey = ‘XXX’; % Replace with your read API key
% ThingSpeak Write API Key for the destination channel
writeAPIKey = ‘XXX’; % Replace with your write API key
%% Read Data %%
% Read all available data from the source channel
data = thingSpeakRead(readChannelID, ‘ReadKey’, readAPIKey, ‘Fields’, [1, 2]);
% Extract the values from the read data
values1 = data(:, 1); % Values from field 1 i.e. Estimated Voltage
values2 = data(:, 2); % Values from field 2 i.e. Input Current
% Determine the number of data points retrieved
numPoints = size(data, 1); % Assign the number of rows in the variable ‘data’ to the variable ‘numPoints’
% Generate timestamps for the data
timeStamps = datetime(‘now’) – minutes(numPoints:-1:1);
% Initialize Y arrays
Y1 = zeros(size(values1)); % Create a new array ‘Y1’ filled with zeros that has same size as the array ‘values1’
Y2 = zeros(size(values2)); % Create a new array ‘Y2’ filled with zeros that has same size as the array ‘values2’
% Perform the operation Y(i) = i * I(i) for each value in the read data
for i = 1:length(values1)
disp([‘Processing index ‘, num2str(i)]);
disp([‘values1(‘, num2str(i), ‘) = ‘, num2str(values1(i))]);
disp([‘values2(‘, num2str(i), ‘) = ‘, num2str(values2(i))]);
Y1(i) = i * values1(i);
Y2(i) = i * values2(i);
disp([‘Y1(‘, num2str(i), ‘) = ‘, num2str(Y1(i))]);
disp([‘Y2(‘, num2str(i), ‘) = ‘, num2str(Y2(i))]);
end
% Write the data to the destination channel with timestamps
thingSpeakWrite(writeChannelID, ‘WriteKey’, writeAPIKey, ‘Values’, [Y1′, Y2′], ‘Fields’, [1, 2], ‘Timestamps’, timeStamps); thingspeak, read channel, write channel, data processing MATLAB Answers — New Questions