April 27, 2018
I want to plot a best fit (2D) line on ThingSpeak.
I am using ThingSpeak MATLAB visualisations and I edited the program from there by adding in the function "lsline;" to plot the best fit line.
My program is as such:
% TODO - Replace the  with channel ID to read data from:
readChannelID = 484262;
% TODO - Replace the  with the Field ID to read data from:
fieldID1 = 1;
%% Read Data %%
[data, time] = thingSpeakRead(readChannelID, 'Field', fieldID1, 'NumPoints', 20);
%% Visualize Data %%
However, I have an error code which says this:
To use 'lsline', the following product must be licensed, installed, and enabled:
Statistics and Machine Learning Toolbox
Error in Create a 2-D line plot 3 (line 21)
I wish to do all of the analysis on ThingSpeak cloud platform, and not have to export the data (out from ThingSpeak) and analyse the trends by uploading data to the actual MATLAB R2018 program.
Is it even possible to plot a best fit line on ThingSpeak itself, based on the data points from my channel? Or can this only be done on the actual MATLAB program?
Also, is it possible to plot a best fit line on MATLAB Analysis instead? (Program above is using MATLAB Visualisation)
March 7, 2017
If you have a license that includes Statistics and Machine learning, then log into thingspeak using the Mathworks account that has the license. You will then be able to use Isline. There are definitely other ways to fit data using the base MATLAB that is available through ThingSpeak. Such a solution will not require a license.
See the example at https://www.mathworks.com/help/thingspeak/Visualize-Correlation-Between-Temperature-and-Humidity.html. The last section at the bottom shows how to use polyfit to do linear regression. Poly fit will also fir to higher order polynomials. There are also functions for fit other types of curves. You can definitely do these operations in ThingSpeak MATLAB Visualizations app or the MATLAB analysis app.
You cannot plot a fit line using MATLAB analysis, but you can determine fit parameters to your data in MATLAB analysis.
The linear regression page shows you how to determine slope and intercept for a line of best fit. https://www.mathworks.com/help/matlab/data_analysis/linear-regression.html
The matrix technique shown will work in MATLAB analysis but you would not be able to visualize our data.
Most Users Ever Online: 114
Currently Browsing this Page:
Guest Posters: 1
Newest Members:gwenbk2, eloisedq3, AEtedesar, RichardWosus, Kellynapse, tejomaya
Administrators: Hans: 387, lee: 457