Marc Capafons Garcia in MATLAB Answers
Última actividad el 13 de Abr. de 2020

Hello! I am trying to create a 3d graph of these that have to be displayed and we got this error when I try to save and execute the matlab code ... I attach the error, the complete matlab code and the web from where the information was taken. Website of the information: https://es.mathworks.com/matlabcentral/mlc-downloads/downloads/submissions/56910/versions/4/previews/html/ThingSpeakWeatherStation.html#2 Graph I want to create: Matlab code: % Channel ID to read data from readChannelID = 803557; % Specify date range dateRange = [datetime('March 7, 2016'),datetime('March 13, 2016')]; % Read data including the timestamp, and channel information. [data,time,channelInfo] = thingSpeakRead(readChannelID,'Fields',1:7,... 'DateRange',dateRange); % Create variables to store different sorts of data temperatureData = data(:,1); humidityData = data(:,2); pressureData = data(:,3); rainData = data(:,4); windSpeedData = data(:,5); windGustData = data(:,6); windDirectionData = data(:,7); % Create a day range vector dayRange = day(dateRange(1):dateRange(2)); % Pre-allocate matrix weatherData = zeros(length(dayRange),24); % Generate temperature 3D bar chart % Get temperature per whole clock for each day for m = 1:length(dayRange) % Loop over all days for n = 1:24 % Loop over 24 hours if any(day(time)==dayRange(m) & hour(time)==n); % Check if data exist for this specific time hourlyData = temperatureData((day(time)==dayRange(m) & hour(time)==n)); % Pull out the hourly temperature from the matrix weatherData(m,n) = hourlyData(1); % Assign the temperature at the time closest to the whole clock end end end % Plot figure h = bar3(datenum(dateRange(1):dateRange(2)), weatherData); for k = 1:length(h) % Change the face color for each bar h(k).CData = h(k).ZData; h(k).FaceColor = 'interp'; end title('Temperature Distribution') xlabel('Hour of Day') ylabel('Date') datetick('y','mmm dd') % Change the Y-Tick to display specified date format ax = gca; ax.XTick = 1:24; % Change the X-Tick to 24 hours ax.YTickLabelRotation = 30; % Rotate label for better display colorbar % Add a color bar to indicate the scaling of color % Generate humidity 3D bar chart % Get humidity per whole clock for each day for m = 1:length(dayRange) % Loop over all days for n = 1:24 % Loop over 24 hours if any(day(time)==dayRange(m) & hour(time)==n); % Check if data exist for this specific time hourlyData = humidityData((day(time)==dayRange(m) & hour(time)==n)); % Pull out the hourly humidity from the matrix weatherData(m,n) = hourlyData(1); % Assign the humidity at the time closest to the whole clock end end end % Plot figure h = bar3(datenum(dateRange(1):dateRange(2)), weatherData); for k = 1:length(h) % Change the face color for each bar h(k).CData = h(k).ZData; h(k).FaceColor = 'interp'; end title('Humidity Distribution') xlabel('Hour of Day') ylabel('Date') datetick('y','mmm dd') % Change the Y-Tick to display specified date format ax = gca; ax.XTick = 1:24; % Change the X-Tick to 24 hours ax.YTickLabelRotation = 30; % Rotate label for better display colorbar % Add a color bar to indicate the scaling of color Error we said: I would really appreciate your help. Thanks. Marc
Ank Agarwal in MATLAB Answers
Última actividad el 18 de Sept. de 2017

I read this page: https://www.mathworks.com/help/thingspeak/plot-a-histogram-with-a-distribution-fit.html I generated a histogram with a gaussian fit using histfit but I also need the correlation coefficient for the fit to the data. How do I obtain it? current code: load('datafile.dat'); ydata=datafile; histfit(ydadta,100);

Acerca de ThingSpeak

The community for students, researchers, and engineers looking to use MATLAB, Simulink, and ThingSpeak for Internet of Things applications. You can find the latest ThingSpeak news, tutorials to jump-start your next IoT project, and a forum to engage in a discussion on your latest cloud-based project. You can see answers to problems other users have solved and share how you solved a problem.