Otávio Vanzelotti in MATLAB Answers
上次活动时间: 2019-10-8

I'm trying to create a pie chart with the energy comsumption of some of my electronic devices. I made a simple code for testing: Flow the logic: 1) Receives energy consumption of a cicle (interval) from TV (field 1) and Lights (field 2) [ESP calculates in X seconds how much energy was used and sends it] 2) In 'Field Chart' I select 'Sum' as 'Daily', so each time it receives an energy consumption this value is added to the previous one. Now about the MATLAB Visualization code: I got a pie chart using 'pie(X)' with X being a vector of only 2 numbers (energy from TV and energy from Lights). But the sum of the only two numbers not equals 100%. One thing that I did notice is that the proportion of the yellow and the blue slices is correct (when compared with the values that are displayed at the Field Charts), but I don't know what is the missing part of the pie. Look at the pie chart that I got: My objective is to show how one device affects the total daily consumption in comparison with another device. So, with the last value added to the daily sum of one field I want to use it as a slice of the pie in the chart. So, the objective is a Daily Pie Chart of Energy Consumtion. I'm also getting the message: "Error using Testing (Pie Chart) (line 20). Channel ID must be a positive integer." But my code doesen't even have 20 lines and my Channel ID is a positive integer. The simple code below: readChannelID = 123456; % exemple of how the channelId written in the original code fieldID1 = 1; fieldID2 = 2; readAPIKey = '6RW0V0UCJ7TPV24R'; etv = thingSpeakRead(readChannelID, 'Field', fieldID1, 'NumPoints', 1, 'Readkey', readAPIKey); % energy from TV eil = thingSpeakRead(readChannelID, 'Field', fieldID2, 'NumPoints', 1, 'Readkey', readAPIKey); % energy from illumination X = [etv eil]; pie(X); Thanks for the help and sorry if i made an english mistake. I'm from Brasil.

关于 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.