Request Error Bars | MATLAB | Forum

Avatar

Please consider registering
Guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —






— Match —





— Forum Options —





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

sp_Feed sp_TopicIcon
Request Error Bars
No permission to create posts
August 24, 2015
3:30 pm
Avatar
BMcC
New Member
Members
Forum Posts: 4
Member Since:
August 24, 2015
sp_UserOfflineSmall Offline

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!

August 25, 2015
7:59 am
Avatar
Rob Purser
Natick, MA

MathWorks
Members
Forum Posts: 46
Member Since:
August 22, 2015
sp_UserOfflineSmall Offline

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!

August 25, 2015
3:07 pm
Avatar
BMcC
New Member
Members
Forum Posts: 4
Member Since:
August 24, 2015
sp_UserOfflineSmall Offline

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!

August 25, 2015
3:54 pm
Avatar
BMcC
New Member
Members
Forum Posts: 4
Member Since:
August 24, 2015
sp_UserOfflineSmall Offline

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."

August 25, 2015
5:40 pm
Avatar
Adarsh_Murthy

MathWorks
Members
Forum Posts: 62
Member Since:
August 25, 2015
sp_UserOfflineSmall Offline

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)

August 25, 2015
7:53 pm
Avatar
Rob Purser
Natick, MA

MathWorks
Members
Forum Posts: 46
Member Since:
August 22, 2015
sp_UserOfflineSmall Offline

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!

August 26, 2015
2:43 pm
Avatar
BMcC
New Member
Members
Forum Posts: 4
Member Since:
August 24, 2015
sp_UserOfflineSmall Offline

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

August 26, 2015
9:24 pm
Avatar
Rob Purser
Natick, MA

MathWorks
Members
Forum Posts: 46
Member Since:
August 22, 2015
sp_UserOfflineSmall Offline

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:
17 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

rw950431: 261

Vinod: 196

piajola: 85

turgo: 70

vespapierre: 63

Adarsh_Murthy: 62

Member Stats:

Guest Posters: 1

Members: 5703

Moderators: 0

Admins: 2

Forum Stats:

Groups: 4

Forums: 17

Topics: 1313

Posts: 4565

Newest Members:

celinabw2, FitoSprayscroma, LunnonGor, lancevl16, bernicenk60, veronicadq18

Administrators: Hans: 387, lee: 457