Mecdettin in MATLAB Answers
최근 활동: 2023년 9월 6일

Hello, I am bulding an app using MATLAB's App designer, But I am facing a problem. In my app I am trying to embed charts of thing speak fields. For example I want to show exactly this plot in my App and to be dynamic which means as the data changes in thing speak, it also changes in my app. (if the method change in embeding the plot between public and private channel please give me the method for both)
Ardish Morawala in MATLAB Answers
최근 활동: 2022년 9월 15일

I wish to upload and plot on channel chart both positive and negative temperatures from DS18B20 sensor. While I can see the positive temperatures properly on the chart, the negative temperatures also show as above zero. The code snippet is as below: if(temp_data & 0x80) { temp_data = (~temp_data)+1; sprintf(esp_buff, "GET /update?api_key=%s&field1=%d", API_WRITE_KEY, -temp_data); } else { sprintf(esp_buff, "GET /update?api_key=%s&field1=%d", API_WRITE_KEY, temp_data); } //sprintf(esp_buff, "GET /update?api_key=%s&field1=%d", API_WRITE_KEY, temp_data); ESP8266_Send(esp_buff); It can be seen that the last two readings which are -6 and -9 deg C,show as +6 and +9 deg C. what should I do to make them come below the zero line?
William Hidevik in Discussions
최근 활동: 2022년 9월 12일

Hi guys, I'm very new to matlab, so this might a rookie mistake. However, it seems that I have messed up some important part with the plot function. The program does not give my any kind of error messages, but still does not plot anything. What can I have done wrong and how do I fix this? Best regards My code: close all for t = -2:0.1:3 if (t<0 || t>1) xvalue = 0; end if (t<= 1 && t>= 0) xvalue = exp(2*t+1); end yvalue = -1*(xvalue) + exp(1); hold on figure(1); plot(t, yvalue); hold off end grid on; My plot function seems to not work try scatter(t, yvalue); You are making a whole bunch of one point plots each time you go through the loop (thus they are blank for plot). I would consider building an array in your loop and then plotting all the data at once, at the end. plot
Mostafa Ibrahim in MATLAB Answers
최근 활동: 2021년 8월 9일

Hey, so I made an app on app designer that reads and writes data to a thingspeak channel. So what I want to do is make a filed on my thingspeak channel that is going to be a map, I want to upload my latitude and logitude data to that map and plot the points. I have been looking for a long time and all I can find was the channel location, but I don't want that, I want to plot multiple points when I click the upload button on my app designer. Any idea on how to do that?
Phillip Maus in MATLAB Answers
최근 활동: 2020년 9월 14일

Hello, I want to plot two values from a thingspeak channel in a graph. If I don't use any optional value for LineSpec, I can't see anything plotted although I don't get an error message and the values on x and y axis are in the correct range. I f I ad for example a 'b.' (for blue points as markers) as LineSpec, I will see the markers but no line. If I ad an '-' for the solid line ('b.-' or 'b-') it doesn't show anything. This seems very strange to me. I just want a solid line. How can I fix this? Many thanks! This is my code: readChannelID = [1....4]; fieldID1 = [1]; fieldID2 = [2]; readAPIKey = 'OA9........MQ'; [data1, time1] = thingSpeakRead(readChannelID, 'Field', fieldID1, 'NumPoints', 600, 'ReadKey', readAPIKey); [data2, time2] = thingSpeakRead(readChannelID, 'Field', fieldID2, 'NumPoints', 600, 'ReadKey', readAPIKey); yyaxis left; plot(time1, data1,'r.') % nothing is plotted if I use just use plot(time1, data1) or if I use plot(time1, data1,'r-') yyaxis right; plot(time2, data2, 'b.');
Andrew Clark in MATLAB Answers
최근 활동: 2020년 2월 12일

I am receiving runtime errors when running this Matlab example [ MathWorks Internet of Things Team (2020). Air Quality Measurements and Visualizations (https://www.mathworks.com/matlabcentral/fileexchange/71908-air-quality-measurements-and-visualizations), MATLAB Central File Exchange. Retrieved February 7, 2020.] using my Thingspeak Public channel data. It sometimes runs successfully, but mostly ends with these error codes. There is obviously some sort of problem with the data being read. I have checked the data in the Channel and in the specific field and it looks ok. I have tried reducing the number of minutes ("NumMinutes") to a lower number but get same result. Perhaps there is a date or time issue, since I am asking for 1440 minutes, which is 24 hours. Can anyone shed any light on what could be causing these issues? Thanks much. This is the code: % This script acquires data from a public ThingSpeak channel located at % the MathWorks Headquarters in Natick, MA, and uses it to calculate % an Air Quality Index (AQI). % Copyright 2019 The MathWorks, Inc. % Prior to running this MATLAB code template, assign the channel ID to read % data from to the 'readChannelID' variable. Also, assign the field ID % within the channel that you want to read data from to plot. % TODO - Replace the [] with channel ID to read data from: %%readChannelID = 357142; readChannelID = 891066; yourChannel = 839634; yourChannelWriteKey = 'xxxxxxxxxxxxxxxxxxx'; % TODO - Replace the [] with the Field ID to read data from: fieldID1 = 2; % Channel Read API Key % If your channel is private, then enter the read API % Key between the '' below: readAPIKey = ''; %% Read Data %% [rawData, time] = thingSpeakRead(readChannelID, 'Field', fieldID1, 'Numminutes', 1440, 'ReadKey', readAPIKey); localTime = time - hours(7); % adjust for local time in Sunnyvale CA %% Run custom function that analyzes collected data, computes AQI and plots collected data returnAQI = analyzeplotAQI(localTime,rawData); %% Send computed AQI to ThingSpeak Channel (Field 1) thingSpeakWrite(yourChannel,returnAQI,'WriteKey',yourChannelWriteKey,'Fields',8); % CUSTOM FUNCTIONS BELOW % Main function that smoothes collected data and calls other custom functions function returnAQI = analyzeplotAQI(localTime,rawData) %% Smooth data smoothData = movmedian(rawData,10); % Find max and plot data smoothDataMax = max(smoothData); plotfun(localTime,rawData,smoothData,smoothDataMax) % Combine smoothed data with time as # of elements are the same smoothParticulateDataTable = table(localTime,smoothData,'VariableNames',{'Time','Particulate_Conc'}); % Calculate AQI pmObs = round(mean(smoothParticulateDataTable{:,2}),1); % Calculate 24 hour running average returnAQI = calculateAQI(pmObs); end %% Plot Data function plotfun(localTime,rawData,smoothData,smoothDataMax) plot(localTime, rawData); hold on plot(localTime,smoothData,'-*') % Plot max of smooth data line(localTime,smoothDataMax * ones(length(localTime),1),'LineStyle','--') title('2.5 micron particulate concentration \mug/m^{3}') xlabel('Time'); ylabel('Concentration \mug/m^{3}'); legend('Collected data','Smoothed data','Max of Smooth Data','Location','best') axis tight hold off end %% Calculate AQI function returnAQI = calculateAQI(pmObs) % Learn about how AQI is calcuated % https://www.epa.gov/outdoor-air-quality-data aqiLow = [0;51;101;151;201;301]; aqiHigh = [50;100;150;200;300;500]; concLow = [0;15.5;40.5;65.5;150.5;250.5]; concHigh = [15.4;40.4;65.4;150.4;250.4;500.4]; % Create Look Up Table lutAQI = table(aqiLow,aqiHigh,concLow,concHigh,... 'VariableNames',{'AQI_low','AQI_high','PM_low','PM_high'}); % Find the necessary equation parameters rowIdx = find(pmObs >= lutAQI.PM_low & pmObs <= lutAQI.PM_high); PM_min = lutAQI.PM_low(rowIdx); PM_max = lutAQI.PM_high(rowIdx); AQI_min = lutAQI.AQI_low(rowIdx); AQI_max = lutAQI.AQI_high(rowIdx); returnAQI = round((((pmObs - PM_min) * (AQI_max - AQI_min))/(PM_max - PM_min)) + AQI_min); end And these are the Output error messages I am getting: Warning: Ignoring extra legend entries. > In legend>process_inputs (line 594) In legend>make_legend (line 335) In legend (line 279) In AQI Calculator>plotfun (line 50) In AQI Calculator>analyzeplotAQI (line 33) In AQI Calculator (line 23) Error using * Incorrect dimensions for matrix multiplication. Check that the number of columns in the first matrix matches the number of rows in the second matrix. To perform elementwise multiplication, use '.*'. Error in AQI Calculator>calculateAQI (line 71) returnAQI = round((((pmObs - PM_min) * (AQI_max - AQI_min))/(PM_max - PM_min)) + AQI_min); Error in AQI Calculator>analyzeplotAQI (line 38) returnAQI = calculateAQI(pmObs); Error in AQI Calculator (line 23) returnAQI = analyzeplotAQI(localTime,rawData);
black in MATLAB Answers
최근 활동: 2019년 9월 22일

I want to label the time axis in a plot with "ddd: HH" (speak "first three letters of the day, then the two digits for the hour in 24-hour format). However, when doing this, the format is applied for some labels, but otheres also print more information like month, day and year. % generate time sequence, last 3 days, 12 hours offset xtickformat('eee: HH') t2 = datetime('today'), t1 = t2-days(3) xData = t1:hours(12):t2 set(gca,'xtick',xData) Leads to:
Loraine Luceñara in MATLAB Answers
최근 활동: 2019년 7월 25일

I've been trying to plot a chart on thingspeak. but the line won't seem to appear. How do I make the line appear? I've tried to change the line to a dashed line, I've also tried to varying the linewidth but all it got me were much bigger markers. I've checked and all the arrays right size. If it helps, the timestamps array is a datetime array. Here is all of my code: % Channel ID to read data from readChannelID = 827912; % Temperature Field ID TemperatureFieldID = 1; % Wind speed Field ID HumidityFieldID = 4; % Channel Read API Key % If your channel is private, then enter the read API % Key between the '' below: readAPIKey = 'CZD7YSPVMXAAI188'; % Read Data. Learn more about the thingSpeakRead function by % going to the Documentation tab on the right side pane of this page. [data, timeStamps] = thingSpeakRead(readChannelID, 'Fields',[TemperatureFieldID HumidityFieldID], ... 'NumPoints', 300, ... 'ReadKey', readAPIKey); % Extract the temperature data from the first column temperatureData = data(:, 1); % Extract the windspeed data from the second column HumidityData = data(:, 2); % Visualize Data yyaxis left plot(timeStamps, temperatureData,'mo-',... 'LineWidth',2,... 'MarkerEdgeColor','k',... 'MarkerFaceColor',[.49 1 .63],... 'MarkerSize',5); ylabel('Temperature'); hold on; yyaxis right plot(timeStamps, HumidityData, '--mo',... 'LineWidth',2,... 'MarkerEdgeColor','k',... 'MarkerFaceColor','b',... 'MarkerSize',5); ylabel('Humdity');

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.