Request Error Bars | MATLAB | Forum

Avatar

Please consider registering
Guest

Search

— Forum Scope —






— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

Register Lost password?
sp_Feed sp_TopicIcon
Request Error Bars
Avatar
BMcC
New Member
Forum Posts: 4
sp_UserOfflineSmall Offline
1
August 24, 2015 - 3:30 pm
sp_Permalink sp_Print

Hi,

Would it be possible to add error bars to the data in a chart?

I'd like to be able to plot the mean value of some sample data +/- one standard deviation on each point represented by an error bar... something like this for example:

http://3.bp.blogspot.com/-aiPECwSj0VE/Uep8hsQ0qtI/AAAAAAAABN0/Iwv5Sv9OJ1I/s1600/error_bars_both.png

Thanks!

Avatar
Rob Purser
Natick, MA

Forum Posts: 46
sp_UserOfflineSmall Offline
2
August 25, 2015 - 7:59 am
sp_Permalink sp_Print

Yes -- you can using the MATLAB errorbar plot.

I'll try to post an example later, but here's the documentation:
http://www.mathworks.com/help/matlab/ref/errorbar.html

-Rob

Senior Development Manager for IoT and Hardware Interfacing for MATLAB at MathWorks.  Visit ThingSpeak.com to explore the IoT Analytic platform that speaks MATLAB made for engineers and scientists.  You can collect, analyze, and act in 5 minutes or less!

Avatar
BMcC
New Member
Forum Posts: 4
sp_UserOfflineSmall Offline
3
August 25, 2015 - 3:07 pm
sp_Permalink sp_Print

Hi Rob,

Thank you for your reply. I'll have a look at the MATLAB link and see if I can figure out what I need to do 🙂

Thanks!

Avatar
BMcC
New Member
Forum Posts: 4
sp_UserOfflineSmall Offline
4
August 25, 2015 - 3:54 pm
sp_Permalink sp_Print

Hi again,

Is it possible to create an error bar plot using MATLAB Visualizations? I can't see an option using thingsSpeakPlot.

If I try to use MATLAB Analysis and the errorbar(x,y,e) function I get an error that states..
"Cannot use MATLAB visualization code "bar(x,y,e)" in the MATLAB Analysis app. You must create a MATLAB Visualization."

Avatar
Adarsh_Murthy

Forum Posts: 59
sp_UserOfflineSmall Offline
5
August 25, 2015 - 5:40 pm
sp_Permalink sp_Print

That is correct, you can create an error bar plot using MATLAB Visualizations App. You will not be able to create an error bar plot in a MATLAB Analysis App.

Create a new MATLAB Visualization App and select "Custom (no starter code)" option from the Templates. Paste the below MATLAB Code in the new MATLAB Visualizations App to generate an example "errorbar" plot.

x = 0:pi/10:pi;
y = sin(x);
e = std(y)*ones(size(x));

errorbar(x,y,e)

Avatar
Rob Purser
Natick, MA

Forum Posts: 46
sp_UserOfflineSmall Offline
6
August 25, 2015 - 7:53 pm
sp_Permalink sp_Print

Hi,

I have an arduino that is contantly writing to ThinkSpeak to monitor the system intake performance. Here's some code that I use to visualize the data associated with that. You should be able to copy/paste this into a MATLAB Visualization verbatim.

numHours = 6;
[data,ts] = thingSpeakRead(52622,'readkey','P3DEWWFW89DVMUIY','NumMinutes',numHours*60,'Fields',1);

% Create hour of day categories to summarize by
hourOfDay = floor(hours(timeofday(ts)));

% Apply the function max, min, mean, and standard deviation to each of the
% hours in the day
sumStats = table;
sumStats.hour = unique(hourOfDay);
sumStats.max = arrayfun(@(x)(max(data(hourOfDay == x))),sumStats.hour);
sumStats.min = arrayfun(@(x)(min(data(hourOfDay == x))),sumStats.hour);
sumStats.mean = arrayfun(@(x)(mean(data(hourOfDay == x))),sumStats.hour);
sumStats.std = arrayfun(@(x)(std(data(hourOfDay == x))),sumStats.hour);

errorbar(sumStats.hour, sumStats.mean,sumStats.std,'d-')
hold on
plot(sumStats.hour, sumStats.max ,'+',...
sumStats.hour, sumStats.min ,'+')
hold off

Senior Development Manager for IoT and Hardware Interfacing for MATLAB at MathWorks.  Visit ThingSpeak.com to explore the IoT Analytic platform that speaks MATLAB made for engineers and scientists.  You can collect, analyze, and act in 5 minutes or less!

Avatar
BMcC
New Member
Forum Posts: 4
sp_UserOfflineSmall Offline
7
August 26, 2015 - 2:43 pm
sp_Permalink sp_Print sp_EditHistory

Thanks Rob - that's got it all working well now 🙂 Thank you!

Thanks also Adash - makes sense now 🙂

Cheers!

Mean CO2 with Errors:
https://thingspeak.com/channels/51602
Smile

Avatar
Rob Purser
Natick, MA

Forum Posts: 46
sp_UserOfflineSmall Offline
8
August 26, 2015 - 9:24 pm
sp_Permalink sp_Print

Looks awesome! Thanks for sharing!
-Rob

Senior Development Manager for IoT and Hardware Interfacing for MATLAB at MathWorks.  Visit ThingSpeak.com to explore the IoT Analytic platform that speaks MATLAB made for engineers and scientists.  You can collect, analyze, and act in 5 minutes or less!

Forum Timezone: America/New_York

Most Users Ever Online: 114

Currently Online:
19 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

rw950431: 252

Vinod: 164

cstapels: 96

piajola: 75

vespapierre: 63

Adarsh_Murthy: 59

Newest Members:

winnieeq69

AutoCheernpen

Bostermet

engladNed

iivenul

olewaeayafaku

Forum Stats:

Groups: 4

Forums: 17

Topics: 1313

Posts: 4565

 

Member Stats:

Guest Posters: 1

Members: 5703

Moderators: 0

Admins: 2

Administrators: Hans, lee